Advertisement
Saleh127

CC c2020q

Oct 3rd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll a[200000];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. test
  13. {
  14. ll c,d,e,f,i,j=0,k,l=0;
  15. cin>>c>>d;
  16. for(i=0;i<c;i++)
  17. {
  18. cin>>a[i];
  19. }
  20. for(i=0;i<c-1;i++)
  21. {
  22. if(a[i]>=d)
  23. {
  24. j++;
  25. a[i+1]+=(a[i]-d);
  26. }
  27. else if(a[i]<d)
  28. {
  29. l=1;
  30. j++;
  31. break;
  32. }
  33. }
  34. if(l)
  35. {
  36. cout<<j<<endl;
  37. continue;
  38. }
  39. j+=(a[c-1]/d);
  40. cout<<j+1<<endl;
  41. }
  42. return 0;
  43. }
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement