fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n,c;
  5. scanf("%d %d",&n,&c);
  6. int t[n],time=0,s=0;
  7.  
  8. scanf("%d",&t[0]);int m=t[0];
  9.  
  10. for(int i=1;i<n;i++){
  11. scanf("%d",&t[i]);time+=t[i];
  12. printf("%d %d\n",time,s);
  13. if(time-m>=c){
  14. s++;
  15. time=0;
  16. m=t[i];
  17. }
  18. }
  19.  
  20. printf("%d",s);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5280KB
stdin
6 5
1 3 7 8 10 12

stdout
3  0
10  0
8  1
18  1
12  2
2