Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created October 9, 2019 03:35
Show Gist options
  • Save surinoel/3c7fee18c372ce65a8f08dd65ffa7372 to your computer and use it in GitHub Desktop.
Save surinoel/3c7fee18c372ce65a8f08dd65ffa7372 to your computer and use it in GitHub Desktop.
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<pair<int, int>> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].first;
v[i].second = i;
}
sort(v.begin(), v.end());
int ans = -1;
for (int i = 0; i < n; i++) {
ans = max(ans, v[i].second - i);
}
cout << ans + 1 << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment