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 100000
int GetBestPosition(int n, int m, int r, int *aa, int *ll, int *rr) {
static int ii[N + 1], rr_[N];
int h, i, n_, n1, i_, k_, k;
for (i = 0; i <= n; i++)
ii[i] = i;
n_ = n + 1;
for (h = 0; h < m; h++) {
ll[h] = ii[ll[h]], rr[h] = ii[rr[h] + 1] - 1;
n1 = 0;
for (i = 0; i < n_; i++)
if (ii[i] <= ll[h] || ii[i] > rr[h])
ii[n1++] = ii[i];
n_ = n1;
}
rr_[n - 1] = n - 1;
for (i = n - 2; i >= 0; i--)
rr_[i] = aa[i] > r ? i : rr_[i + 1];
i_ = -1, k_ = -1;
for (i = 0; i < n; i++) {
k = 0;
for (h = 0; h < m; h++)
if (ll[h] <= i && i <= rr[h]) {
if (rr_[ll[h]] < rr[h])
break;
k++;
}
if (k_ < k)
k_ = k, i_ = i;
}
return i_;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |