This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, a[500001];
map < pair < int, int >, int > m;
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
int len = abs(a[i] - i);
m[{(len + 1) / 2 + min(a[i], i), max(a[i], i) - (len + 1) / 2}]++;
}
int l = -1, r = -1;
int mx = 0;
for(auto it : m){
if(it.second > mx){
mx = it.second;
l = it.first.first;
r = it.first.second;
}
}
int mn = min(l - 1, n - r);
cout << a[l - mn] << " " << a[r + mn];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |