#include <bits/stdc++.h>
using namespace std;
#define arr array
#define vct vector
const int MX_N = 1e4 + 5, MX_Q = 1e2 + 5;
int n, l;
arr<int, MX_N> vl;
int q;
arr<int, MX_Q> qry;
arr<arr<int, MX_N>, 2> sm;
vct<int> sms;
arr<arr<int, MX_N>, MX_Q> ans;
void cmp() {
for (int i = n; i >= 1; i--) {
int prt = i % 2, opp_prt = (i + 1) % 2;
for (int j = 1; j <= n; j++) sm[prt][j] = (vl[i] == vl[j]) + sm[opp_prt][j + 1];
sms.clear();
for (int j = 1; j <= n - l + 1; j++)
if (j != i) sms.push_back(sm[prt][j]);
for (int j = 1; j <= q; j++)
ans[j][i] = count_if(sms.begin(), sms.end(), [j](int x) { return x >= l - qry[j]; } );
for (int j = 1; j <= n; j++) {
int nw_i = i + l - 1, nw_j = j + l - 1;
if (max(nw_i, nw_j) > n) continue;
sm[prt][j] -= (vl[nw_i] == vl[nw_j]);
}
}
}
int main() {
// freopen("lttry.in", "r", stdin);
cin >> n >> l;
for (int i = 1; i <= n; i++) cin >> vl[i];
cin >> q;
for (int i = 1; i <= q; i++) cin >> qry[i];
cmp();
for (int i = 1; i <= q; i++) {
for (int j = 1; j <= n - l + 1; j++) cout << ans[i][j] << " ";
cout << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
24 ms |
532 KB |
Output is correct |
14 |
Correct |
46 ms |
600 KB |
Output is correct |
15 |
Correct |
29 ms |
604 KB |
Output is correct |
16 |
Correct |
63 ms |
600 KB |
Output is correct |
17 |
Correct |
57 ms |
628 KB |
Output is correct |
18 |
Correct |
57 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
331 ms |
600 KB |
Output is correct |
2 |
Correct |
323 ms |
600 KB |
Output is correct |
3 |
Correct |
321 ms |
600 KB |
Output is correct |
4 |
Correct |
322 ms |
600 KB |
Output is correct |
5 |
Correct |
222 ms |
600 KB |
Output is correct |
6 |
Correct |
325 ms |
604 KB |
Output is correct |
7 |
Correct |
231 ms |
720 KB |
Output is correct |
8 |
Correct |
261 ms |
600 KB |
Output is correct |
9 |
Correct |
328 ms |
740 KB |
Output is correct |
10 |
Correct |
320 ms |
748 KB |
Output is correct |
11 |
Correct |
26 ms |
348 KB |
Output is correct |
12 |
Correct |
226 ms |
696 KB |
Output is correct |
13 |
Correct |
239 ms |
600 KB |
Output is correct |
14 |
Correct |
256 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
331 ms |
600 KB |
Output is correct |
2 |
Correct |
323 ms |
600 KB |
Output is correct |
3 |
Correct |
321 ms |
600 KB |
Output is correct |
4 |
Correct |
322 ms |
600 KB |
Output is correct |
5 |
Correct |
222 ms |
600 KB |
Output is correct |
6 |
Correct |
325 ms |
604 KB |
Output is correct |
7 |
Correct |
231 ms |
720 KB |
Output is correct |
8 |
Correct |
261 ms |
600 KB |
Output is correct |
9 |
Correct |
328 ms |
740 KB |
Output is correct |
10 |
Correct |
320 ms |
748 KB |
Output is correct |
11 |
Correct |
26 ms |
348 KB |
Output is correct |
12 |
Correct |
226 ms |
696 KB |
Output is correct |
13 |
Correct |
239 ms |
600 KB |
Output is correct |
14 |
Correct |
256 ms |
700 KB |
Output is correct |
15 |
Correct |
316 ms |
684 KB |
Output is correct |
16 |
Correct |
303 ms |
856 KB |
Output is correct |
17 |
Correct |
324 ms |
748 KB |
Output is correct |
18 |
Correct |
342 ms |
604 KB |
Output is correct |
19 |
Correct |
333 ms |
856 KB |
Output is correct |
20 |
Correct |
323 ms |
600 KB |
Output is correct |
21 |
Correct |
325 ms |
564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
24 ms |
532 KB |
Output is correct |
14 |
Correct |
46 ms |
600 KB |
Output is correct |
15 |
Correct |
29 ms |
604 KB |
Output is correct |
16 |
Correct |
63 ms |
600 KB |
Output is correct |
17 |
Correct |
57 ms |
628 KB |
Output is correct |
18 |
Correct |
57 ms |
604 KB |
Output is correct |
19 |
Correct |
331 ms |
600 KB |
Output is correct |
20 |
Correct |
323 ms |
600 KB |
Output is correct |
21 |
Correct |
321 ms |
600 KB |
Output is correct |
22 |
Correct |
322 ms |
600 KB |
Output is correct |
23 |
Correct |
222 ms |
600 KB |
Output is correct |
24 |
Correct |
325 ms |
604 KB |
Output is correct |
25 |
Correct |
231 ms |
720 KB |
Output is correct |
26 |
Correct |
261 ms |
600 KB |
Output is correct |
27 |
Correct |
328 ms |
740 KB |
Output is correct |
28 |
Correct |
320 ms |
748 KB |
Output is correct |
29 |
Correct |
26 ms |
348 KB |
Output is correct |
30 |
Correct |
226 ms |
696 KB |
Output is correct |
31 |
Correct |
239 ms |
600 KB |
Output is correct |
32 |
Correct |
256 ms |
700 KB |
Output is correct |
33 |
Correct |
316 ms |
684 KB |
Output is correct |
34 |
Correct |
303 ms |
856 KB |
Output is correct |
35 |
Correct |
324 ms |
748 KB |
Output is correct |
36 |
Correct |
342 ms |
604 KB |
Output is correct |
37 |
Correct |
333 ms |
856 KB |
Output is correct |
38 |
Correct |
323 ms |
600 KB |
Output is correct |
39 |
Correct |
325 ms |
564 KB |
Output is correct |
40 |
Correct |
1561 ms |
2128 KB |
Output is correct |
41 |
Correct |
278 ms |
1360 KB |
Output is correct |
42 |
Correct |
1560 ms |
2132 KB |
Output is correct |
43 |
Correct |
1505 ms |
1844 KB |
Output is correct |
44 |
Correct |
1694 ms |
1876 KB |
Output is correct |
45 |
Execution timed out |
3061 ms |
2636 KB |
Time limit exceeded |
46 |
Halted |
0 ms |
0 KB |
- |