fork 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];s++;
  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(t[i]-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 5284KB
stdin
10 3
0 3 4 6 9 12 15 17 19 20
stdout
3  1
4  2
10  2
9  3
12  4
15  5
17  6
36  6
20  7
7