# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
694999 | rainboy | Sushi (JOI16_sushi) | C11 | 53 ms | 5868 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 400000
int main() {
static int aa[N];
int n, q, i;
scanf("%d%d", &n, &q);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
if (n <= 2000 && q <= 2000)
while (q--) {
int s, t, a, tmp;
scanf("%d%d%d", &s, &t, &a), s--, t--;
if (s <= t) {
for (i = s; i <= t; i++)
if (a < aa[i])
tmp = a, a = aa[i], aa[i] = tmp;
} else {
for (i = s; i < n; i++)
if (a < aa[i])
tmp = a, a = aa[i], aa[i] = tmp;
for (i = 0; i <= t; i++)
if (a < aa[i])
tmp = a, a = aa[i], aa[i] = tmp;
}
printf("%d\n", a);
}
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... |