# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1025921 |
2024-07-17T11:15:34 Z |
vjudge1 |
Doktor (COCI17_doktor) |
C++17 |
|
97 ms |
15120 KB |
#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 + 1;
}
int cnt[3 * 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], i), k = min(idx[i], i);
int profit = cnt[i + idx[i]] - (pref[j - 1] - pref[k - 1]);
if(abs(idx[i] - i) % 2 == 0)
{
int mid = (i + idx[i]) / 2;
if(a[mid - 1] == mid) profit++;
}
// cerr << "profit : " << profit << endl;
if(profit > mx)
{
mx = profit;
ans = {a[k - 1], a[j - 1]};
}
cnt[idx[i] + i] = 0;
}
cout << ans.first << ' ' << ans.second << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2904 KB |
Output is correct |
2 |
Correct |
19 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
97 ms |
15120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
8784 KB |
Output is correct |
2 |
Correct |
96 ms |
14932 KB |
Output is correct |