# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522125 | LucaDantas | Lottery (CEOI18_lot) | C++17 | 1309 ms | 8736 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 <vector>
#include <algorithm>
constexpr int maxn = 1e4+10, maxq = 105;
int a[maxn], dist[maxn<<1], qtd[maxn], n;
void add(int x) {
for(int i = 0; i < n; i++)
if(a[i] != a[x]) ++dist[i - x + maxn]; // adiciono o maxn pra normalizar no meio
}
void rmv(int x) {
for(int i = 0; i < n; i++)
if(a[i] != a[x]) --dist[i - x + maxn]; // adiciono o maxn pra normalizar no meio
}
int prox[maxn], ans[maxn][maxq], ans_certo[maxn][maxq];
int main() {
int l; scanf("%d %d", &n, &l);
for(int i = 0; i < n; i++)
scanf("%d", a+i);
for(int i = 0; i < l; i++)
add(i);
int q; scanf("%d", &q);
std::vector<std::pair<int,int>> td(q);
for(int i = 0, x; i < q; i++)
scanf("%d", &x), td[i] = {x, i};
std::sort(td.begin(), td.end());
for(int i = 0; i < q; i++)
prox[td[i].first] = i+1;
for(int i = n-1; i >= 0; i--)
if(!prox[i]) prox[i] = prox[i+1];
for(int i = 0; i < n-l+1; i++) {
for(int j = maxn-i; j < maxn + n-l+1-i; j++)
if(j != maxn) ans[i][prox[dist[j]]]++;
for(int j = 2; j <= q; j++)
ans[i][j] += ans[i][j-1];
for(int j = 0; j < q; j++)
ans_certo[i][j+1] = ans[i][td[j].second+1];
rmv(i);
add(i+l);
}
for(int j = 1; j <= q; j++) {
for(int i = 0; i < n-l+1; i++)
printf("%d ", ans_certo[i][j]);
puts("");
}
}
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... |