Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int people;
  7. cin >> people;
  8. int dead = 0;
  9. // 1 = alive AND 0 = dead
  10. vector <int> alive(people, 1);
  11. for(int i=0; i<people; ++i){
  12. int leng;
  13. cin >> leng;
  14. for(int f=(i-1); f>((i-1)-leng); --f){
  15. if(f >= 0 && alive[f] == 1){
  16. alive[f] = 0;
  17. ++dead;
  18. }
  19. }
  20. }
  21. cout << people - dead << "\n";
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement