fork download
  1. // NOTE: it is recommended to use this even if you don't understand the following code.
  2.  
  3. #include <fstream>
  4. #include <iostream>
  5. #include <string>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11. // uncomment the two following lines if you want to read/write from files
  12. // ifstream cin("input.txt");
  13. // ofstream cout("output.txt");
  14.  
  15. int N;
  16. cin >> N;
  17.  
  18. vector<int> S(N);
  19. for (int i = 0; i < N; ++i)
  20. cin >> S[i];
  21.  
  22. int ans = N;
  23.  
  24.  
  25. for (int i=0; i<N; i++)
  26. {
  27. if(S[N-1]>S[i]){
  28.  
  29. ans--;}
  30. S[N]=S[i];
  31.  
  32. }
  33.  
  34.  
  35.  
  36. cout << ans << endl;
  37.  
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0.01s 5288KB
stdin
5
3 7 2 5 4
stdout
3