Submission #473651

#TimeUsernameProblemLanguageResultExecution timeMemory
473651MamdouhNDoktor (COCI17_doktor)C++11
90 / 100
872 ms58700 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" map<pair<int,int>,int>idk; map<pair<int,int>,pair<int,int>>k; main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 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 }]++; if(y>k[{ x-dist , y+dist }].second)k[{ x-dist , y+dist }] = {x,y}; lol.push_back(doingnothing); } int x = 0; pair<int,int>ans; for(auto v:idk) { int st = k[{v.first.first,v.first.second}].first; int en = k[{v.first.first,v.first.second}].second; int z = lol[en+1] - lol[st]; if(v.second-z> x) { x = v.second; ans = {st,en}; } } cout<<ar[ans.first]<<" "<<ar[ans.second]<<endl; }

Compilation message (stderr)

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