Submission #166782

#TimeUsernameProblemLanguageResultExecution timeMemory
166782muhi1112Doktor (COCI17_doktor)C++17
70 / 100
109 ms37880 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define f1 first #define s2 second #define pb push_back #define mp make_pair #define ll long long #define fri(a) freopen(a,"r",stdin); #define fro(a) freopen(a,"w",stdout); const int N=5e5+5; int n,pre[N],dizi[N],ans1,ans,maxl,maxr; vector<int>v[N]; int main(){ //fri("in.txt"); //fro("out.txt"); ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n; for(int i=1;i<=n;i++){ cin>>dizi[i]; v[dizi[i]+i].pb(abs(dizi[i]-i)); if(dizi[i]==i)pre[i]++; } for(int i=1;i<=n;i++){ pre[i]+=pre[i-1]; //cout<<pre[i]<<endl; } for(int i=0;i<=2*n;i++){ sort(v[i].begin(),v[i].end()); for(int j=0;j<v[i].size();j++){ int l=(i-v[i][j])/2; int r=(i+v[i][j])/2; ans1=j+pre[l]+pre[n]-pre[r]; //cout<<l<<" "<<r<<" "<<ans1<<endl; if(ans1>ans){ maxl=l; maxr=r; ans=ans1; } } } cout<<dizi[maxl]<<" "<<dizi[maxr]<<endl; return 0; }

Compilation message (stderr)

doktor.cpp: In function 'int main()':
doktor.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<v[i].size();j++){
               ~^~~~~~~~~~~~
#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...