# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259888 | pedroslrey | Lottery (CEOI18_lot) | C++17 | 3047 ms | 704 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 <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 10;
int xs[MAXN];
int ans[MAXN];
int main() {
int n, l;
scanf("%d%d", &n, &l);
for (int i = 0; i < n; ++i)
scanf("%d", &xs[i]);
int q;
scanf("%d", &q);
while (q--) {
int k;
scanf("%d", &k);
for (int space = 1; space + l - 1 < n; ++space) {
int diffs = 0;
for (int i = 0; i < l; ++i)
if (xs[i] != xs[i + space])
++diffs;
if (diffs <= k)
++ans[0], ++ans[space];
for (int i = 1; i + space + l - 1 < n; ++i) {
if (xs[i-1] != xs[i + space - 1])
--diffs;
if (xs[i + l - 1] != xs[i + l + space - 1])
++diffs;
if (diffs <= k)
++ans[i], ++ans[i + space];
}
}
for (int i = 0; i < n - l + 1; ++i) {
printf("%d ", ans[i]);
ans[i] = 0;
}
printf("\n");
}
}
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... |