답안 #161370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161370 2019-11-02T05:28:07 Z rama_pang Lottery (CEOI18_lot) C++14
80 / 100
3000 ms 3456 KB
#include <bits/stdc++.h>
using namespace std;

int N, L, q, Q[100], A[10005];
int ans[100][10005];

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];
    
    /* The segment compared is segment i...(i + L - 1) and (i + shift)...(i + L + shift - 1) */
    for (int shift = 1; shift + L - 1 < N; shift++) {
        int 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
            for (int j = 0; j < q; j++) 
                if (Q[j] >= L - similiar) ans[j][i]++, ans[j][i + shift]++;
            

            if (A[i] == A[i + shift]) similiar--;
            if (A[i + L] == A[i + shift + L]) similiar++;
        }
    }

    for (int i = 0; i < q; i++) {
        for (int j = 0; j < N - L + 1; j++) cout << ans[i][j] << " ";
        cout << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 22 ms 504 KB Output is correct
14 Correct 25 ms 448 KB Output is correct
15 Correct 16 ms 524 KB Output is correct
16 Correct 61 ms 632 KB Output is correct
17 Correct 56 ms 664 KB Output is correct
18 Correct 56 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 437 ms 496 KB Output is correct
2 Correct 633 ms 508 KB Output is correct
3 Correct 236 ms 504 KB Output is correct
4 Correct 156 ms 504 KB Output is correct
5 Correct 62 ms 528 KB Output is correct
6 Correct 145 ms 504 KB Output is correct
7 Correct 63 ms 584 KB Output is correct
8 Correct 108 ms 504 KB Output is correct
9 Correct 153 ms 632 KB Output is correct
10 Correct 157 ms 560 KB Output is correct
11 Correct 16 ms 376 KB Output is correct
12 Correct 120 ms 632 KB Output is correct
13 Correct 88 ms 504 KB Output is correct
14 Correct 97 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 437 ms 496 KB Output is correct
2 Correct 633 ms 508 KB Output is correct
3 Correct 236 ms 504 KB Output is correct
4 Correct 156 ms 504 KB Output is correct
5 Correct 62 ms 528 KB Output is correct
6 Correct 145 ms 504 KB Output is correct
7 Correct 63 ms 584 KB Output is correct
8 Correct 108 ms 504 KB Output is correct
9 Correct 153 ms 632 KB Output is correct
10 Correct 157 ms 560 KB Output is correct
11 Correct 16 ms 376 KB Output is correct
12 Correct 120 ms 632 KB Output is correct
13 Correct 88 ms 504 KB Output is correct
14 Correct 97 ms 632 KB Output is correct
15 Correct 292 ms 504 KB Output is correct
16 Correct 137 ms 504 KB Output is correct
17 Correct 182 ms 568 KB Output is correct
18 Correct 159 ms 644 KB Output is correct
19 Correct 158 ms 568 KB Output is correct
20 Correct 158 ms 572 KB Output is correct
21 Correct 157 ms 568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 22 ms 504 KB Output is correct
14 Correct 25 ms 448 KB Output is correct
15 Correct 16 ms 524 KB Output is correct
16 Correct 61 ms 632 KB Output is correct
17 Correct 56 ms 664 KB Output is correct
18 Correct 56 ms 632 KB Output is correct
19 Correct 437 ms 496 KB Output is correct
20 Correct 633 ms 508 KB Output is correct
21 Correct 236 ms 504 KB Output is correct
22 Correct 156 ms 504 KB Output is correct
23 Correct 62 ms 528 KB Output is correct
24 Correct 145 ms 504 KB Output is correct
25 Correct 63 ms 584 KB Output is correct
26 Correct 108 ms 504 KB Output is correct
27 Correct 153 ms 632 KB Output is correct
28 Correct 157 ms 560 KB Output is correct
29 Correct 16 ms 376 KB Output is correct
30 Correct 120 ms 632 KB Output is correct
31 Correct 88 ms 504 KB Output is correct
32 Correct 97 ms 632 KB Output is correct
33 Correct 292 ms 504 KB Output is correct
34 Correct 137 ms 504 KB Output is correct
35 Correct 182 ms 568 KB Output is correct
36 Correct 159 ms 644 KB Output is correct
37 Correct 158 ms 568 KB Output is correct
38 Correct 158 ms 572 KB Output is correct
39 Correct 157 ms 568 KB Output is correct
40 Correct 1759 ms 1832 KB Output is correct
41 Correct 30 ms 692 KB Output is correct
42 Correct 1782 ms 2024 KB Output is correct
43 Correct 1752 ms 1848 KB Output is correct
44 Correct 1655 ms 1756 KB Output is correct
45 Execution timed out 3051 ms 3456 KB Time limit exceeded
46 Halted 0 ms 0 KB -