# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545919 | rainboy | Lottery (CEOI18_lot) | C11 | 832 ms | 8208 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 10000
#define Q 100
int main() {
static int aa[N], hh[N + 1], kk[Q], pp[Q + 1][N];
int n, q, l, h, i, d, k;
scanf("%d%d", &n, &l);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
scanf("%d", &q);
for (h = 0; h < q; h++) {
scanf("%d", &kk[h]);
if (kk[h] < l)
hh[kk[h] + 1]++;
}
for (k = 1; k <= l; k++)
hh[k] += hh[k - 1];
for (d = 1; d < n; d++)
for (i = 0, k = 0; i + d < n; i++) {
if (aa[i] != aa[i + d])
k++;
if (i >= l - 1) {
h = hh[k];
pp[h][i - l + 1]++, pp[h][i + d - l + 1]++;
if (aa[i - l + 1] != aa[i + d - l + 1])
k--;
}
}
for (h = 1; h <= q; h++)
for (i = 0; i + l <= n; i++)
pp[h][i] += pp[h - 1][i];
for (h = 0; h < q; h++) {
for (i = 0; i + l <= n; i++)
printf("%d ", pp[hh[kk[h]]][i]);
printf("\n");
}
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... |