O_Egor

var 10

Jun 2nd, 2023
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.     vector<int> v(n);
  11.     int mx = INT_MIN, mx_pos1(-1), mx_pos2(-1);
  12.     for(int i = 0; i < n; ++i)
  13.     {
  14.         cin >> v[i];
  15.         if(v[i] > mx)
  16.         {
  17.             mx = v[i];
  18.             mx_pos1 = i;
  19.         }
  20.         else if(v[i] == mx)
  21.         {
  22.             mx_pos2 = i;
  23.         }
  24.     }
  25.     if(mx_pos1 < mx_pos2)
  26.     {
  27.         v.erase(v.begin() + mx_pos1 + 1, v.begin() + mx_pos2);
  28.     }
  29.  
  30.     for(int i : v)
  31.     {
  32.         cout << i << ' ';
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment