Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int people;
- cin >> people;
- int dead = 0;
- // 1 = alive AND 0 = dead
- vector <int> alive(people, 1);
- for(int i=0; i<people; ++i){
- int leng;
- cin >> leng;
- for(int f=(i-1); f>((i-1)-leng); --f){
- if(f >= 0 && alive[f] == 1){
- alive[f] = 0;
- ++dead;
- }
- }
- }
- cout << people - dead << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement