# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
97829 |
2019-02-18T18:39:51 Z |
dalgerok |
Doktor (COCI17_doktor) |
C++17 |
|
317 ms |
45944 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, a[N], pref[N];
vector < pair < int, int > > q[2 * N];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
pref[i] = pref[i - 1] + (a[i] == i);
int l = i, r = a[i];
if(l > r){
swap(l, r);
}
q[l + r].push_back(make_pair(l, r));
}
pair < int, pair < int, int > > ans = make_pair(pref[n], make_pair(1, 1));
for(int i = 1; i <= 2 * n; i++){
if(q[i].empty()){
continue;
}
sort(q[i].rbegin(), q[i].rend());
for(int j = 0; j < (int)q[i].size(); j++){
int l = q[i][j].first,
r = q[i][j].second;
int val = j + 1 + pref[n] - (pref[r] - pref[l - 1]);
ans = max(ans, make_pair(val, q[i][j]));
}
}
cout << a[ans.second.first] << " " << a[ans.second.second];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
23808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
23772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
23756 KB |
Output is correct |
2 |
Correct |
23 ms |
23840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23936 KB |
Output is correct |
2 |
Correct |
26 ms |
23928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23928 KB |
Output is correct |
2 |
Correct |
22 ms |
23936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
23936 KB |
Output is correct |
2 |
Correct |
23 ms |
23908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
24312 KB |
Output is correct |
2 |
Correct |
99 ms |
32128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
26764 KB |
Output is correct |
2 |
Correct |
45 ms |
26268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
317 ms |
39436 KB |
Output is correct |
2 |
Correct |
167 ms |
35296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
32888 KB |
Output is correct |
2 |
Correct |
136 ms |
45944 KB |
Output is correct |