Submission #1025902

#TimeUsernameProblemLanguageResultExecution timeMemory
1025902vjudge1Doktor (COCI17_doktor)C++17
70 / 100
94 ms11580 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], idx[1 + n]; for(int i = 0; i < n; i ++) { cin >> a[i]; idx[a[i]] = i; } int cnt[2 * n] = {}; for(int i = 1; i <= n; i ++) cnt[idx[i] + i]++; int pref[n + 1]; for(int i = 0; i < n; i ++) { pref[i + 1] = pref[i]; if(i + 1 == a[i]) pref[i + 1]++; } pair<int,int> ans = {1, 1}; int mx = 0; for(int i = 1; i <= n; i ++) { int j = max(idx[i] + 1, i), k = min(idx[i] + 1, i); int profit = cnt[i + idx[i]]; if(profit > mx) { mx = profit; ans = {a[k - 1], a[j - 1]}; } } cout << ans.first << ' ' << ans.second << endl; 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...