Submission #96854

#TimeUsernameProblemLanguageResultExecution timeMemory
96854Rouge_HugoDoktor (COCI17_doktor)C++14
90 / 100
1069 ms59028 KiB
#include <bits/stdc++.h> using namespace std; const int mw=5*100002; int pr[mw],a[mw],t[mw]; map<double,vector<pair<int,int>>>m; int main() {ios_base::sync_with_stdio(false); cin.tie(NULL); int sum=0; int n;cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; t[a[i]]=i; if (a[i]==i) { sum++; } pr[i]=sum; } for(int i=1;i<=n;i++) { double u=(a[i]+i)/2.0; m[u].push_back({min(a[i],i),max(a[i],i)}); } int mx=0; pair<int,int>b; for(auto it :m) {sum=0; sort(m[it.first].begin(),m[it.first].end()); reverse (m[it.first].begin(),m[it.first].end()); for(auto pp:m[it.first]) { if (mx<sum+1+pr[n]-pr[pp.second]+pr[pp.first-1]) { mx=sum+1+pr[n]-pr[pp.second]+pr[pp.first-1]; b=pp; } sum++; } } cout<<a[b.first]<<" "<<a[b.second]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...