# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471175 | rainboy | Doktor (COCI17_doktor) | C11 | 89 ms | 13096 KiB |
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 <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 (stderr)
# | 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... |