Submission #116827

#TimeUsernameProblemLanguageResultExecution timeMemory
116827minhcoolDoktor (COCI17_doktor)C++17
40 / 100
148 ms34832 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n, a[500001], pre[500001], mx = -1, ans1, ans2; vector<int> change[500001]; signed main(){ ios_base::sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; pre[i] = pre[i - 1]; if(a[i] == i) pre[i]++; if((a[i] + i) % 2) continue; change[(a[i] + i) / 2].push_back(abs(a[i] - i) / 2); } for(int i = 1; i <= n; i++){ if(!change[i].size()) continue; sort(change[i].begin(), change[i].end()); for(int j = change[i].size() - 1; j >= 0; j--){ if(mx < (j + 1 - pre[change[i][j] + i] + pre[i - change[i][j] - 1])){ mx = j + 1 - pre[change[i][j] + i] + pre[i - change[i][j] - 1]; ans1 = a[i - change[i][j]]; ans2 = a[i + change[i][j]]; } } } cout << ans1 << " " << ans2; }
#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...