# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
235132 |
2020-05-27T07:10:30 Z |
NONAME |
Doktor (COCI17_doktor) |
C++17 |
|
1000 ms |
4296 KB |
#include <bits/stdc++.h>
#define N 5 * 100500
using namespace std;
int n, pf[N], a[N], ans, al = 0, ar = 0;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
pf[i] = (i - 1 < 0) ? 0 : pf[i - 1];
pf[i] += (a[i] == i);
}
for (int i = 0; i < n; i++) {
int l = i, r = a[i];
if (l > r)
swap(l, r);
int cur = ((l - 1 < 0) ? 0 : pf[l - 1]) + (pf[n - 1] - pf[r]);
while (l < r) {
cur += (a[l] == r);
cur += (a[r] == l);
l++, r--;
}
if (l == r && a[l] == l)
cur++;
if (cur > ans) {
ans = cur;
al = i;
ar = a[i];
}
}
cout << a[al] + 1 << ' ' << a[ar] + 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Failed |
6 ms |
384 KB |
Checker failed - contact admins or jury |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
11 ms |
384 KB |
Checker failed - contact admins or jury |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
384 KB |
Output is correct |
2 |
Failed |
5 ms |
384 KB |
Checker failed - contact admins or jury |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
1084 ms |
2708 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
1016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
4296 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
2552 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |