Submission #473631

#TimeUsernameProblemLanguageResultExecution timeMemory
473631MamdouhNDoktor (COCI17_doktor)C++17
80 / 100
606 ms38216 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" map<pair<int,int>,int>idk; main() { int n; cin>>n; int ar[n]; int doingnothing=0; vector<int>lol; lol.push_back(0); for(int i=0;i<n;i++) { cin>>ar[i]; if(ar[i]==i+1)doingnothing++; int x = min(ar[i]-1,i); int y = max(ar[i]-1,i); int dist = min(x - 0 , n - y-1); //cout<<x-dist<<" "<<y+dist<<endl; idk[{ x-dist , y+dist }]++; lol.push_back(doingnothing); } int x = 0; pair<int,int>ans; for(auto v:idk) { int z = lol[v.first.second+1] - lol[v.first.first]; if(v.second-z>x) { x = v.second; ans = v.first; } } cout<<ar[ans.first]<<" "<<ar[ans.second]<<endl; }

Compilation message (stderr)

doktor.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
#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...