Created
December 5, 2017 13:29
-
-
Save gamazeps/0bca4b45b1fe72ca8e5b70baba7f50e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <sstream> | |
#include <string> | |
#include <vector> | |
#include <climits> | |
using namespace std; | |
int main() { | |
string buff; | |
vector<int> in; | |
while(getline(cin, buff)) { | |
istringstream iss(buff); | |
int tmp; | |
iss >> tmp; | |
in.push_back(tmp); | |
} | |
int pos(0); | |
int steps(0); | |
do { | |
int tmp(in[pos]); | |
steps+=1; | |
if (in[pos] > 2) { | |
in[pos]--; | |
} else { | |
in[pos]++; | |
} | |
pos += tmp; | |
} while (pos < in.size()); | |
cout << steps << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment