# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
161379 |
2019-11-02T06:06:43 Z |
rama_pang |
Lottery (CEOI18_lot) |
C++14 |
|
1425 ms |
8376 KB |
#include <bits/stdc++.h>
using namespace std;
int N, L, q, A[10005];
int ans[105][10005];
int true_ans[105][10005];
pair<int, int> Q[105];
int pos[105];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N >> L; for (int i = 0; i < N; i++) cin >> A[i];
cin >> q; for (int i = 0; i < q; i++) cin >> Q[i].first;
for (int i = 0; i < q; i++) Q[i].second = i;
sort(Q, Q + q);
for (int i = 0; i < q; i++) pos[Q[i].second] = i;
/* The segment compared is segment i...(i + L - 1) and (i + shift)...(i + L + shift - 1) */
for (int shift = 1, similiar = 0; shift + L - 1 < N; shift++, similiar = 0) {
for (int i = 0; i < L; i++)
if (A[i] == A[i + shift]) similiar++;
for (int i = 0; i + shift + L - 1 < N; i++) { // then sliding window can be used
int j = lower_bound(Q, Q + q, make_pair(L - similiar, -1)) - Q;
ans[j][i]++, ans[j][i + shift]++; // Add 1 to the answer for the lowest Q possible
if (A[i] == A[i + shift]) similiar--;
if (A[i + L] == A[i + shift + L]) similiar++;
}
}
/* If Q[i] <= Q[j], then all answers from Q[i] can be used in Q[j] */
for (int i = 0; i < N - L + 1; i++)
for (int j = 1; j < q; j++)
ans[j][i] += ans[j - 1][i];
for (int i = 0; i < q; i++) {
for (int j = 0; j < N - L + 1; j++)
cout << ans[pos[i]][j] << " ";
cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
26 ms |
504 KB |
Output is correct |
14 |
Correct |
17 ms |
632 KB |
Output is correct |
15 |
Correct |
15 ms |
504 KB |
Output is correct |
16 |
Correct |
27 ms |
760 KB |
Output is correct |
17 |
Correct |
24 ms |
632 KB |
Output is correct |
18 |
Correct |
24 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
712 ms |
604 KB |
Output is correct |
2 |
Correct |
935 ms |
520 KB |
Output is correct |
3 |
Correct |
476 ms |
632 KB |
Output is correct |
4 |
Correct |
419 ms |
632 KB |
Output is correct |
5 |
Correct |
129 ms |
376 KB |
Output is correct |
6 |
Correct |
384 ms |
516 KB |
Output is correct |
7 |
Correct |
85 ms |
504 KB |
Output is correct |
8 |
Correct |
157 ms |
504 KB |
Output is correct |
9 |
Correct |
398 ms |
524 KB |
Output is correct |
10 |
Correct |
414 ms |
516 KB |
Output is correct |
11 |
Correct |
25 ms |
376 KB |
Output is correct |
12 |
Correct |
234 ms |
504 KB |
Output is correct |
13 |
Correct |
178 ms |
476 KB |
Output is correct |
14 |
Correct |
186 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
712 ms |
604 KB |
Output is correct |
2 |
Correct |
935 ms |
520 KB |
Output is correct |
3 |
Correct |
476 ms |
632 KB |
Output is correct |
4 |
Correct |
419 ms |
632 KB |
Output is correct |
5 |
Correct |
129 ms |
376 KB |
Output is correct |
6 |
Correct |
384 ms |
516 KB |
Output is correct |
7 |
Correct |
85 ms |
504 KB |
Output is correct |
8 |
Correct |
157 ms |
504 KB |
Output is correct |
9 |
Correct |
398 ms |
524 KB |
Output is correct |
10 |
Correct |
414 ms |
516 KB |
Output is correct |
11 |
Correct |
25 ms |
376 KB |
Output is correct |
12 |
Correct |
234 ms |
504 KB |
Output is correct |
13 |
Correct |
178 ms |
476 KB |
Output is correct |
14 |
Correct |
186 ms |
460 KB |
Output is correct |
15 |
Correct |
454 ms |
548 KB |
Output is correct |
16 |
Correct |
366 ms |
500 KB |
Output is correct |
17 |
Correct |
442 ms |
604 KB |
Output is correct |
18 |
Correct |
422 ms |
384 KB |
Output is correct |
19 |
Correct |
557 ms |
512 KB |
Output is correct |
20 |
Correct |
440 ms |
604 KB |
Output is correct |
21 |
Correct |
424 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
26 ms |
504 KB |
Output is correct |
14 |
Correct |
17 ms |
632 KB |
Output is correct |
15 |
Correct |
15 ms |
504 KB |
Output is correct |
16 |
Correct |
27 ms |
760 KB |
Output is correct |
17 |
Correct |
24 ms |
632 KB |
Output is correct |
18 |
Correct |
24 ms |
632 KB |
Output is correct |
19 |
Correct |
712 ms |
604 KB |
Output is correct |
20 |
Correct |
935 ms |
520 KB |
Output is correct |
21 |
Correct |
476 ms |
632 KB |
Output is correct |
22 |
Correct |
419 ms |
632 KB |
Output is correct |
23 |
Correct |
129 ms |
376 KB |
Output is correct |
24 |
Correct |
384 ms |
516 KB |
Output is correct |
25 |
Correct |
85 ms |
504 KB |
Output is correct |
26 |
Correct |
157 ms |
504 KB |
Output is correct |
27 |
Correct |
398 ms |
524 KB |
Output is correct |
28 |
Correct |
414 ms |
516 KB |
Output is correct |
29 |
Correct |
25 ms |
376 KB |
Output is correct |
30 |
Correct |
234 ms |
504 KB |
Output is correct |
31 |
Correct |
178 ms |
476 KB |
Output is correct |
32 |
Correct |
186 ms |
460 KB |
Output is correct |
33 |
Correct |
454 ms |
548 KB |
Output is correct |
34 |
Correct |
366 ms |
500 KB |
Output is correct |
35 |
Correct |
442 ms |
604 KB |
Output is correct |
36 |
Correct |
422 ms |
384 KB |
Output is correct |
37 |
Correct |
557 ms |
512 KB |
Output is correct |
38 |
Correct |
440 ms |
604 KB |
Output is correct |
39 |
Correct |
424 ms |
632 KB |
Output is correct |
40 |
Correct |
1167 ms |
1944 KB |
Output is correct |
41 |
Correct |
19 ms |
632 KB |
Output is correct |
42 |
Correct |
672 ms |
2092 KB |
Output is correct |
43 |
Correct |
769 ms |
1784 KB |
Output is correct |
44 |
Correct |
622 ms |
1784 KB |
Output is correct |
45 |
Correct |
1425 ms |
8312 KB |
Output is correct |
46 |
Correct |
28 ms |
1532 KB |
Output is correct |
47 |
Correct |
953 ms |
8376 KB |
Output is correct |
48 |
Correct |
822 ms |
6520 KB |
Output is correct |
49 |
Correct |
834 ms |
7404 KB |
Output is correct |