| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1291562 | thaibeo123 | Lottery (CEOI18_lot) | C++20 | 206 ms | 8384 KiB |
#include <bits/stdc++.h>
using namespace std;
#define NAME "A"
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define MASK(x) (1ll << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
const int N = 1e4 + 5;
int n, l, q;
int a[N], ans[N][105], que[N], b[N], nxt[N];
void input() {
cin >> n >> l;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
cin >> q;
for (int i = 1; i <= q; i++) {
cin >> que[i];
b[i] = que[i];
}
sort(b + 1, b + 1 + q);
b[q + 1] = l;
int j = 0;
for (int i = 1; i <= q + 1; i++) {
while (j <= b[i]) {
nxt[j] = i;
j++;
}
}
}
void solve() {
for (int j = 2; j <= n - l + 1; j++) {
int diff = 0;
for (int k = j; k < j + l; k++) {
diff += (a[k - j + 1] != a[k]);
}
int i = 1;
int jj = j;
while (jj <= n - l + 1) {
ans[i][nxt[diff]]++;
ans[jj][nxt[diff]]++;
diff = diff - (a[i] != a[jj]) + (a[i + l] != a[jj + l]);
i++, jj++;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= q; j++) {
ans[i][j] += ans[i][j - 1];
}
}
for (int i = 1; i <= q; i++) {
for (int j = 1; j <= n - l + 1; j++) {
cout << ans[j][nxt[que[i]]] << " ";
}
cout << "\n";
}
}
signed main() {
if (fopen(NAME".INP", "r")) {
freopen(NAME".INP", "r", stdin);
freopen(NAME".OUT", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
int t = 1;
//cin >> t;
while (t--) {
input();
solve();
}
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... | ||||
