fork download
  1. #include <bits/stdc++.h>//zero f160
  2. using namespace std;
  3.  
  4. const int MaxN=1e4;
  5. int T,N,v,now=0,nxt=1,ans=1,pvt=0;
  6. int main() {
  7. vector<int> pos;
  8. cin>>T>>N;
  9. for(int n=0;n<N;n++){
  10. cin>>v;
  11. pos.push_back(v);
  12. }
  13. for(int n=0;n<N;n++){
  14. if(pos[n]-pvt>T){
  15. ans+=1;
  16. pvt=pos[n-1];
  17. }
  18. }
  19. cout<<ans;
  20. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
1