이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, l; cin >> n >> l;
int a[n + 1];
a[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int q; cin >> q;
int k[q], k2[q];
for (int i = 0; i < q; i++) {
cin >> k[i]; k2[i] = k[i];
}
sort(k2, k2 + q);
int prf[n + 1];
prf[0] = 0;
int res[n + 1][q + 1];
memset(res, 0, sizeof(res));
for (int j = 1; j < n; j++) {
for (int i = 1; i <= n - j; i++) {
prf[i] = prf[i - 1] + (a[i] != a[i + j]);
}
for (int i = 1; i + j + l - 1 <= n; i++) {
int p = lower_bound(k2, k2 + q, prf[i + l - 1] - prf[i - 1]) - k2;
res[i][p]++;
res[i + j][p]++;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j < q; j++) {
res[i][j] += res[i][j - 1];
}
}
for (int i = 0; i < q; i++) {
for (int j = 1; j <= n - l + 1; j++) {
cout << res[j][lower_bound(k2, k2 + q, k[i]) - k2] << " ";
}
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... |