Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- vector<int> v(n);
- int mx = INT_MIN, mx_pos1(-1), mx_pos2(-1);
- for(int i = 0; i < n; ++i)
- {
- cin >> v[i];
- if(v[i] > mx)
- {
- mx = v[i];
- mx_pos1 = i;
- }
- else if(v[i] == mx)
- {
- mx_pos2 = i;
- }
- }
- if(mx_pos1 < mx_pos2)
- {
- v.erase(v.begin() + mx_pos1 + 1, v.begin() + mx_pos2);
- }
- for(int i : v)
- {
- cout << i << ' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment