Last active
December 24, 2015 23:09
-
-
Save karupayun/2411239a46116fb79aff to your computer and use it in GitHub Desktop.
Solucion al problema A del Good Bye 2014
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <cstdlib> | |
#include <cstring> | |
#include <string> | |
#include <vector> | |
#include <cmath> | |
#include <queue> | |
#include <set> | |
#include <map> | |
using namespace std; | |
#define dprint(v) cout << #v"=" << v << endl | |
#define forr(i, a, b) for(int i=(a); i<(b); i++) | |
#define forn(i, n) forr(i, 0, n) | |
#define dforn(i, n) for(int i=(n)-1; i>=0; i--) | |
#define forall(it,v) for(typeof((v).begin()) it=(v).begin();it!=(v).end();++it) | |
#define sz(c) ((int)c.size()) | |
#define zero(v) memset(v, 0, sizeof(v)) | |
typedef long long ll; | |
#define ii pair<int, int> | |
#define mkp make_pair | |
#define fst first | |
#define snd second | |
#define pb push_back | |
ll t,r,b,n,m,k,rt; | |
string s; | |
int a[100000]; | |
int main() | |
{ | |
#ifndef ONLINE_JUDGE | |
//~ freopen("a.in", "r", stdin); | |
#endif | |
while (cin >> n >> k){ | |
rt = 0; | |
forn (i,n-1) | |
cin >> a[i]; | |
a[n-1] = 2; | |
int j = 0; | |
while (j <= n-1){ | |
if (j == k-1) | |
rt = 1; | |
j+= a[j]; | |
} | |
if (rt) | |
cout << "YES"; | |
else | |
cout << "NO"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment