# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1067871 | sleepntsheep | Archery (IOI09_archery) | C++17 | 2097 ms | 472 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 <cstdio>
#include <array>
using namespace std;
int n, r, s[400], ans = 1e9, q[400], opt;
int check() {
array<int, 400> p, e;
for (int i = 0; i < n * 2; ++i) p[i] = q[i];
for (int ii = 0; ii < r; ++ii) {
int u = p[0], v = p[1];
if (s[u] < s[v]) e[0] = u, e[n * 2 - 1] = v;
else e[0] = v, e[n * 2 - 1] = u;
for (int j = 2; j < n * 2; j += 2) {
int u = p[j], v = p[j + 1];
if (s[u] < s[v]) {
e[(j - 2) + 1] = u;
e[j] = v;
} else {
e[1 + (j - 2)] = v;
e[j] = u;
}
}
p = e;
}
for (int i = 0; i < 400; ++i) if (e[i] == 0) return (i + 1) / 2;
__builtin_unreachable();
}
int main() {
scanf("%d%d", &n, &r);
for (int i = 0; i < n * 2; ++i)
scanf("%d", s + i), q[i] = i;
if (ans >= check()) ans = check(), opt = 1;
for (int i = 1; i < n * 2; ++i) {
int o = 0;
for (int j = 1; j <= i; ++j) q[o++] = j;
q[o++] = 0;
for (int j = i + 1; j < n * 2; ++j) q[o++] = j;
if (ans >= check()) ans = check(), opt = (i + 2) / 2;
}
printf("%d", opt);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |