#include <bits/stdc++.h>
#define int long long
using namespace std;
int cmp(pair<int,int> a, pair<int,int> b) {
if(a.first > b.first) {
return 1;
}
if(a.first == b.first) {
if(a.second < b.second) {
return 1;
}
}
return 0;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<pair<int,int>> V;
for(int i = 1; i <= n; i++) {
int a;
cin >> a;
V.push_back({a, i});
}
sort(V.begin(), V.end(), cmp);
int ans = 1;
for(int i = 1; i < V.size(); i++) {
if(V[i].second < V[i - 1].second) {
ans += 1;
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |