This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
vector<long long> v,w,so;v.push_back(2);
for(int i = 0;i<n;i++){
int x;cin>>x;
w.push_back(x);
so.push_back(x);
}
sort(so.begin(),so.end());
int z = 2;
map<int,int>cmp;
for(int i = 0;i<n;i++){
cmp[so[i]] = z++;
if(i&&so[i]==so[i-1])z--;
}
for(int i = 0;i<n;i++){
v.push_back(cmp[w[i]]*2);
}
long long pre[cmp[so[n-1]]*2+1]={0};
for(int i = 0;i<n;i++){
if(v[i]<v[i+1]){
pre[v[i+1]]--;
pre[v[i]]++;
}
}
long long ma = 0 , cur = 0;
for(int i = 2;i<=cmp[so[n-1]]*2;i++){
cur+=pre[i];
ma = max(ma,cur);
}
cout<<ma<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |