#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
284 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
3 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
284 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
3 ms |
336 KB |
Output is correct |
13 |
Correct |
40 ms |
360 KB |
Output is correct |
14 |
Correct |
17 ms |
516 KB |
Output is correct |
15 |
Correct |
9 ms |
456 KB |
Output is correct |
16 |
Correct |
17 ms |
508 KB |
Output is correct |
17 |
Correct |
26 ms |
504 KB |
Output is correct |
18 |
Correct |
14 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
440 KB |
Output is correct |
2 |
Correct |
335 ms |
484 KB |
Output is correct |
3 |
Correct |
270 ms |
480 KB |
Output is correct |
4 |
Correct |
454 ms |
552 KB |
Output is correct |
5 |
Correct |
119 ms |
548 KB |
Output is correct |
6 |
Correct |
242 ms |
544 KB |
Output is correct |
7 |
Correct |
289 ms |
544 KB |
Output is correct |
8 |
Correct |
186 ms |
556 KB |
Output is correct |
9 |
Correct |
302 ms |
536 KB |
Output is correct |
10 |
Correct |
297 ms |
540 KB |
Output is correct |
11 |
Correct |
29 ms |
368 KB |
Output is correct |
12 |
Correct |
148 ms |
528 KB |
Output is correct |
13 |
Correct |
128 ms |
540 KB |
Output is correct |
14 |
Correct |
240 ms |
548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
440 KB |
Output is correct |
2 |
Correct |
335 ms |
484 KB |
Output is correct |
3 |
Correct |
270 ms |
480 KB |
Output is correct |
4 |
Correct |
454 ms |
552 KB |
Output is correct |
5 |
Correct |
119 ms |
548 KB |
Output is correct |
6 |
Correct |
242 ms |
544 KB |
Output is correct |
7 |
Correct |
289 ms |
544 KB |
Output is correct |
8 |
Correct |
186 ms |
556 KB |
Output is correct |
9 |
Correct |
302 ms |
536 KB |
Output is correct |
10 |
Correct |
297 ms |
540 KB |
Output is correct |
11 |
Correct |
29 ms |
368 KB |
Output is correct |
12 |
Correct |
148 ms |
528 KB |
Output is correct |
13 |
Correct |
128 ms |
540 KB |
Output is correct |
14 |
Correct |
240 ms |
548 KB |
Output is correct |
15 |
Correct |
275 ms |
472 KB |
Output is correct |
16 |
Correct |
248 ms |
560 KB |
Output is correct |
17 |
Correct |
403 ms |
584 KB |
Output is correct |
18 |
Correct |
355 ms |
552 KB |
Output is correct |
19 |
Correct |
281 ms |
560 KB |
Output is correct |
20 |
Correct |
270 ms |
556 KB |
Output is correct |
21 |
Correct |
271 ms |
540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
284 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
3 ms |
336 KB |
Output is correct |
13 |
Correct |
40 ms |
360 KB |
Output is correct |
14 |
Correct |
17 ms |
516 KB |
Output is correct |
15 |
Correct |
9 ms |
456 KB |
Output is correct |
16 |
Correct |
17 ms |
508 KB |
Output is correct |
17 |
Correct |
26 ms |
504 KB |
Output is correct |
18 |
Correct |
14 ms |
504 KB |
Output is correct |
19 |
Correct |
374 ms |
440 KB |
Output is correct |
20 |
Correct |
335 ms |
484 KB |
Output is correct |
21 |
Correct |
270 ms |
480 KB |
Output is correct |
22 |
Correct |
454 ms |
552 KB |
Output is correct |
23 |
Correct |
119 ms |
548 KB |
Output is correct |
24 |
Correct |
242 ms |
544 KB |
Output is correct |
25 |
Correct |
289 ms |
544 KB |
Output is correct |
26 |
Correct |
186 ms |
556 KB |
Output is correct |
27 |
Correct |
302 ms |
536 KB |
Output is correct |
28 |
Correct |
297 ms |
540 KB |
Output is correct |
29 |
Correct |
29 ms |
368 KB |
Output is correct |
30 |
Correct |
148 ms |
528 KB |
Output is correct |
31 |
Correct |
128 ms |
540 KB |
Output is correct |
32 |
Correct |
240 ms |
548 KB |
Output is correct |
33 |
Correct |
275 ms |
472 KB |
Output is correct |
34 |
Correct |
248 ms |
560 KB |
Output is correct |
35 |
Correct |
403 ms |
584 KB |
Output is correct |
36 |
Correct |
355 ms |
552 KB |
Output is correct |
37 |
Correct |
281 ms |
560 KB |
Output is correct |
38 |
Correct |
270 ms |
556 KB |
Output is correct |
39 |
Correct |
271 ms |
540 KB |
Output is correct |
40 |
Correct |
518 ms |
1980 KB |
Output is correct |
41 |
Correct |
47 ms |
1304 KB |
Output is correct |
42 |
Correct |
427 ms |
1988 KB |
Output is correct |
43 |
Correct |
410 ms |
1676 KB |
Output is correct |
44 |
Correct |
410 ms |
1808 KB |
Output is correct |
45 |
Correct |
934 ms |
8184 KB |
Output is correct |
46 |
Correct |
56 ms |
4692 KB |
Output is correct |
47 |
Correct |
639 ms |
8196 KB |
Output is correct |
48 |
Correct |
554 ms |
6468 KB |
Output is correct |
49 |
Correct |
532 ms |
7124 KB |
Output is correct |