Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {
- int n, i, ans=0;
- cin >> n;
- vector< pair<int,int> > a(n);
- for (i = 0; i < n; i++) {
- cin >> a[i].first;
- a[i].second = i;
- }
- sort(a.begin(), a.end());
- for (i = 0; i < n; i++) {
- if (ans < a[i].second-i) {
- ans = a[i].second - i;
- }
- }
- cout << ans + 1 << '\n';
- return 0;
- }
Add Comment
Please, Sign In to add comment