Advertisement
Manioc

SPREAD2

Oct 12th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define MAX 1000007
  3.  
  4. using namespace std;
  5.  
  6. int arr[MAX];
  7. int main(){
  8.     int q; scanf("%d", &q);
  9.     while(q--){
  10.         int n; scanf("%d", &n);
  11.         for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
  12.  
  13.         int idx = 1, day = 0;
  14.         long long pick = arr[0];
  15.         while(idx < n){
  16.             long long acum = 0;
  17.             for(; idx < n && pick >= 0; idx++, pick--){
  18.                 acum += arr[idx];
  19.             }
  20.             pick = acum;
  21.             day++;
  22.         }
  23.         printf("%d\n", day);
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement