#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'
const int MXN = 1e4, MXQ = 100;
int freq[MXQ+1][MXN+2];
int main() {
#ifdef shiven
freopen("test.in", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, l; cin >> n >> l;
vi nums(n);
for_(i, 0, n) cin >> nums[i];
int q; cin >> q;
vector<ii> qrs(q);
for_(i, 0, q) {
cin >> qrs[i].first;
qrs[i].second = i;
}
sort(qrs.begin(), qrs.end());
for_(d, 1, n+1) {
vi temp(n);
for_(j, d, n) if (nums[j] != nums[j-d]) temp[j] += 1;
for_(i, d, n) temp[i] += temp[i-1];
for_(j, d, n-l+1) {
int dist = temp[j+l-1] - (j > 0 ? temp[j-1] : 0);
int idx = lower_bound(qrs.begin(), qrs.end(), (ii) {dist, -1}) - qrs.begin();
if (idx < q) {
freq[qrs[idx].second][j] += 1; freq[qrs[idx].second][j-d] += 1;
}
}
}
for_(i, 0, q) for_(j, 0, n-l+1) if (i > 0) freq[qrs[i].second][j] += freq[qrs[i-1].second][j];
for_(i, 0, q) {
for_(j, 0, n-l+1) cout << freq[i][j] << " ";
cout << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
30 ms |
464 KB |
Output is correct |
14 |
Correct |
19 ms |
640 KB |
Output is correct |
15 |
Correct |
15 ms |
512 KB |
Output is correct |
16 |
Correct |
22 ms |
632 KB |
Output is correct |
17 |
Correct |
20 ms |
640 KB |
Output is correct |
18 |
Correct |
22 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
683 ms |
512 KB |
Output is correct |
2 |
Correct |
604 ms |
632 KB |
Output is correct |
3 |
Correct |
387 ms |
632 KB |
Output is correct |
4 |
Correct |
336 ms |
540 KB |
Output is correct |
5 |
Correct |
254 ms |
504 KB |
Output is correct |
6 |
Correct |
328 ms |
484 KB |
Output is correct |
7 |
Correct |
309 ms |
504 KB |
Output is correct |
8 |
Correct |
386 ms |
500 KB |
Output is correct |
9 |
Correct |
346 ms |
632 KB |
Output is correct |
10 |
Correct |
345 ms |
512 KB |
Output is correct |
11 |
Correct |
30 ms |
384 KB |
Output is correct |
12 |
Correct |
250 ms |
464 KB |
Output is correct |
13 |
Correct |
272 ms |
504 KB |
Output is correct |
14 |
Correct |
276 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
683 ms |
512 KB |
Output is correct |
2 |
Correct |
604 ms |
632 KB |
Output is correct |
3 |
Correct |
387 ms |
632 KB |
Output is correct |
4 |
Correct |
336 ms |
540 KB |
Output is correct |
5 |
Correct |
254 ms |
504 KB |
Output is correct |
6 |
Correct |
328 ms |
484 KB |
Output is correct |
7 |
Correct |
309 ms |
504 KB |
Output is correct |
8 |
Correct |
386 ms |
500 KB |
Output is correct |
9 |
Correct |
346 ms |
632 KB |
Output is correct |
10 |
Correct |
345 ms |
512 KB |
Output is correct |
11 |
Correct |
30 ms |
384 KB |
Output is correct |
12 |
Correct |
250 ms |
464 KB |
Output is correct |
13 |
Correct |
272 ms |
504 KB |
Output is correct |
14 |
Correct |
276 ms |
504 KB |
Output is correct |
15 |
Correct |
476 ms |
512 KB |
Output is correct |
16 |
Correct |
324 ms |
504 KB |
Output is correct |
17 |
Correct |
367 ms |
504 KB |
Output is correct |
18 |
Correct |
339 ms |
504 KB |
Output is correct |
19 |
Correct |
339 ms |
504 KB |
Output is correct |
20 |
Correct |
345 ms |
512 KB |
Output is correct |
21 |
Correct |
338 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
30 ms |
464 KB |
Output is correct |
14 |
Correct |
19 ms |
640 KB |
Output is correct |
15 |
Correct |
15 ms |
512 KB |
Output is correct |
16 |
Correct |
22 ms |
632 KB |
Output is correct |
17 |
Correct |
20 ms |
640 KB |
Output is correct |
18 |
Correct |
22 ms |
632 KB |
Output is correct |
19 |
Correct |
683 ms |
512 KB |
Output is correct |
20 |
Correct |
604 ms |
632 KB |
Output is correct |
21 |
Correct |
387 ms |
632 KB |
Output is correct |
22 |
Correct |
336 ms |
540 KB |
Output is correct |
23 |
Correct |
254 ms |
504 KB |
Output is correct |
24 |
Correct |
328 ms |
484 KB |
Output is correct |
25 |
Correct |
309 ms |
504 KB |
Output is correct |
26 |
Correct |
386 ms |
500 KB |
Output is correct |
27 |
Correct |
346 ms |
632 KB |
Output is correct |
28 |
Correct |
345 ms |
512 KB |
Output is correct |
29 |
Correct |
30 ms |
384 KB |
Output is correct |
30 |
Correct |
250 ms |
464 KB |
Output is correct |
31 |
Correct |
272 ms |
504 KB |
Output is correct |
32 |
Correct |
276 ms |
504 KB |
Output is correct |
33 |
Correct |
476 ms |
512 KB |
Output is correct |
34 |
Correct |
324 ms |
504 KB |
Output is correct |
35 |
Correct |
367 ms |
504 KB |
Output is correct |
36 |
Correct |
339 ms |
504 KB |
Output is correct |
37 |
Correct |
339 ms |
504 KB |
Output is correct |
38 |
Correct |
345 ms |
512 KB |
Output is correct |
39 |
Correct |
338 ms |
512 KB |
Output is correct |
40 |
Correct |
1061 ms |
2040 KB |
Output is correct |
41 |
Correct |
222 ms |
760 KB |
Output is correct |
42 |
Correct |
534 ms |
2168 KB |
Output is correct |
43 |
Correct |
491 ms |
1784 KB |
Output is correct |
44 |
Correct |
496 ms |
1912 KB |
Output is correct |
45 |
Correct |
1517 ms |
8376 KB |
Output is correct |
46 |
Correct |
237 ms |
1656 KB |
Output is correct |
47 |
Correct |
899 ms |
8440 KB |
Output is correct |
48 |
Correct |
658 ms |
6696 KB |
Output is correct |
49 |
Correct |
649 ms |
7288 KB |
Output is correct |