답안 #161378

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

int N, L, q, A[10005];
int ans[100][10005];
int true_ans[100][10005];
pair<int, int> Q[100];
int pos[100];

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; 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";
    }
}
# 결과 실행 시간 메모리 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 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 632 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 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 632 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 26 ms 504 KB Output is correct
14 Correct 16 ms 632 KB Output is correct
15 Correct 14 ms 504 KB Output is correct
16 Correct 35 ms 864 KB Output is correct
17 Correct 23 ms 632 KB Output is correct
18 Correct 24 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 668 ms 504 KB Output is correct
2 Correct 907 ms 540 KB Output is correct
3 Correct 476 ms 632 KB Output is correct
4 Correct 417 ms 540 KB Output is correct
5 Correct 127 ms 504 KB Output is correct
6 Correct 379 ms 524 KB Output is correct
7 Correct 86 ms 376 KB Output is correct
8 Correct 148 ms 476 KB Output is correct
9 Correct 399 ms 504 KB Output is correct
10 Correct 410 ms 512 KB Output is correct
11 Correct 20 ms 376 KB Output is correct
12 Correct 234 ms 592 KB Output is correct
13 Correct 177 ms 504 KB Output is correct
14 Correct 193 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 668 ms 504 KB Output is correct
2 Correct 907 ms 540 KB Output is correct
3 Correct 476 ms 632 KB Output is correct
4 Correct 417 ms 540 KB Output is correct
5 Correct 127 ms 504 KB Output is correct
6 Correct 379 ms 524 KB Output is correct
7 Correct 86 ms 376 KB Output is correct
8 Correct 148 ms 476 KB Output is correct
9 Correct 399 ms 504 KB Output is correct
10 Correct 410 ms 512 KB Output is correct
11 Correct 20 ms 376 KB Output is correct
12 Correct 234 ms 592 KB Output is correct
13 Correct 177 ms 504 KB Output is correct
14 Correct 193 ms 504 KB Output is correct
15 Correct 456 ms 504 KB Output is correct
16 Correct 362 ms 504 KB Output is correct
17 Correct 454 ms 632 KB Output is correct
18 Correct 423 ms 616 KB Output is correct
19 Correct 421 ms 508 KB Output is correct
20 Correct 428 ms 504 KB Output is correct
21 Correct 425 ms 632 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 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 632 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 26 ms 504 KB Output is correct
14 Correct 16 ms 632 KB Output is correct
15 Correct 14 ms 504 KB Output is correct
16 Correct 35 ms 864 KB Output is correct
17 Correct 23 ms 632 KB Output is correct
18 Correct 24 ms 632 KB Output is correct
19 Correct 668 ms 504 KB Output is correct
20 Correct 907 ms 540 KB Output is correct
21 Correct 476 ms 632 KB Output is correct
22 Correct 417 ms 540 KB Output is correct
23 Correct 127 ms 504 KB Output is correct
24 Correct 379 ms 524 KB Output is correct
25 Correct 86 ms 376 KB Output is correct
26 Correct 148 ms 476 KB Output is correct
27 Correct 399 ms 504 KB Output is correct
28 Correct 410 ms 512 KB Output is correct
29 Correct 20 ms 376 KB Output is correct
30 Correct 234 ms 592 KB Output is correct
31 Correct 177 ms 504 KB Output is correct
32 Correct 193 ms 504 KB Output is correct
33 Correct 456 ms 504 KB Output is correct
34 Correct 362 ms 504 KB Output is correct
35 Correct 454 ms 632 KB Output is correct
36 Correct 423 ms 616 KB Output is correct
37 Correct 421 ms 508 KB Output is correct
38 Correct 428 ms 504 KB Output is correct
39 Correct 425 ms 632 KB Output is correct
40 Correct 1203 ms 1944 KB Output is correct
41 Correct 20 ms 1272 KB Output is correct
42 Correct 674 ms 2188 KB Output is correct
43 Correct 637 ms 1912 KB Output is correct
44 Correct 639 ms 1848 KB Output is correct
45 Correct 1430 ms 8176 KB Output is correct
46 Incorrect 34 ms 4728 KB Output isn't correct
47 Halted 0 ms 0 KB -