fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main(){
  6. int N;
  7. int C = 1;
  8. cin >> N;
  9. vector<int> S(N);
  10. vector<int> E(N);
  11.  
  12. for(int i = 0; i < N; i++){
  13. cin >> S[i] >> E[i];
  14. }
  15.  
  16. for(int i = 1; i < N; i++){
  17. if(S[i] >= E[i-1]){
  18. C++;
  19. }else{
  20. E[i] = E[i-1];
  21. }
  22. }
  23.  
  24. cout << C;
  25.  
  26. }
Success #stdin #stdout 0.01s 5276KB
stdin
5
10 30
20 40
30 60
40 80
60 100
stdout
3