이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 10005, Q = 105;
int n, l, q;
int a[N], qu[Q], b[Q], id[N], pf[N], res[N][Q];
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> l; --l;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
cin >> q;
for (int i = 1; i <= q; ++i) {
cin >> qu[i];
b[i] = qu[i];
}
sort(b + 1, b + q + 1);
for (int i = 1, j = 0; i <= n; ++i) {
while (j <= q && b[j] < i) {
++j;
}
id[i] = j;
}
for (int d = 1; d <= n; ++d) {
for (int i = 1; i + d <= n; ++i) {
pf[i] = pf[i - 1] + (a[i] != a[i + d]);
}
for (int i = 1; i + d + l <= n; ++i) {
int k = pf[i + l] - pf[i - 1];
++res[i][id[k]];
++res[i + d][id[k]];
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= q; ++j) {
res[i][j] += res[i][j - 1];
}
}
for (int i = 1; i <= q; ++i) {
for (int j = 1; j + l <= n; ++j) {
cout << res[j][id[qu[i]]] << " ";
}
cout << "\n";
}
return 0;
}
# | 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... |