# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471175 | 2021-09-07T15:39:52 Z | rainboy | Doktor (COCI17_doktor) | C | 89 ms | 13096 KB |
#include <stdio.h> #define N 500000 int main() { static int pp[N], qq[N], kk[N], ll[N + N]; int n, i, i_, j_, k_; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &pp[i]), pp[i]--; qq[pp[i]] = i; if (i == pp[i]) kk[i]++; } for (i = 1; i < n; i++) kk[i] += kk[i - 1]; i_ = j_ = k_ = -1; for (i = n - 1; i >= 0; i--) { int k; if (i <= pp[i]) { k = ++ll[i + pp[i]] - (kk[pp[i]] - (i == 0 ? 0 : kk[i - 1])); if (k_ < k) k_ = k, i_ = i, j_ = pp[i]; } if (i != pp[i] && i <= qq[i]) { k = ++ll[i + qq[i]] - (kk[qq[i]] - (i == 0 ? 0 : kk[i - 1])); if (k_ < k) k_ = k, i_ = i, j_ = qq[i]; } } printf("%d %d\n", pp[i_] + 1, pp[j_] + 1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 288 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 284 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 552 KB | Output is correct |
2 | Correct | 48 ms | 5664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 2508 KB | Output is correct |
2 | Correct | 14 ms | 2000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 89 ms | 13096 KB | Output is correct |
2 | Correct | 75 ms | 9412 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 7756 KB | Output is correct |
2 | Correct | 77 ms | 12848 KB | Output is correct |