Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. long int n, i;
  7. long int a[3000001],b[3000001];
  8. cin >>n;
  9. for(i = 0; i < n; i++){
  10. cin >>a[i];
  11. b[i] = 0;
  12. }
  13. long int max = 0, sum = 0;
  14. for(i=0; i < n; i++){
  15. sum = sum + 1;
  16. if(a[i] <=400000){b[i + a[i]]++;}
  17. sum = sum - b[i];
  18. if(sum > max){
  19. max = sum;
  20. }
  21. }
  22. cout <<max;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement