답안 #967706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967706 2024-04-22T16:25:21 Z Charizard2021 Lottery (CEOI18_lot) C++17
100 / 100
567 ms 6732 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, l;
    cin >> n >> l;
    vector<int> a(1 + n);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int q;
    cin >> q;
    vector<int> queries(1 + q);
    vector<int> orig(1 + q);
    for(int i = 1; i <= q; i++){
        cin >> queries[i];
        orig[i] = queries[i];
    }
    sort(queries.begin(), queries.end());
    vector<short> idx(1 + l);
    int cur = 1;
    for(int i = 0; i <= l; i++){
        while(cur <= q && queries[cur] < i){
            cur++;
        }
        idx[i] = cur;
    }
    vector<vector<short> > A(n - l + 2, vector<short>(1 + q, 0));
    for(int j = 1; j <= n - l; j++){
        int curDiff =0 ;
        for(int i = 0; i < l; i++){
            if(a[1 + i] != a[j + 1 + i]){
                curDiff++;
            }
        }
        if(queries.back() >= curDiff){
            A[1][idx[curDiff]]++;
            A[j + 1][idx[curDiff]]++;
        }
        for(int cur = 2; cur + j <= n - l + 1; cur++){
            if(a[cur - 1] != a[cur - 1 + j]){
                curDiff--;
            }
            if(a[cur + l - 1] != a[cur + l - 1 + j]){
                curDiff++;
            }
            if(queries.back() >= curDiff){
                A[cur][idx[curDiff]]++;
                A[j + cur][idx[curDiff]]++;
            }
        }
    }
    for(int i = 1; i <= n - l + 1; i++){
        for(int j = 1; j <= q; j++){
            A[i][j] += A[i][j - 1];
        }
    }
    for(int j = 1; j <= q; j++){
        for(int i = 1; i <= n - l + 1; i++){
            cout << A[i][idx[orig[j]]] << " ";
        }
        cout << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 8 ms 564 KB Output is correct
14 Correct 6 ms 600 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 1004 KB Output is correct
2 Correct 432 ms 860 KB Output is correct
3 Correct 105 ms 1004 KB Output is correct
4 Correct 63 ms 1000 KB Output is correct
5 Correct 37 ms 940 KB Output is correct
6 Correct 61 ms 860 KB Output is correct
7 Correct 56 ms 848 KB Output is correct
8 Correct 80 ms 956 KB Output is correct
9 Correct 75 ms 1144 KB Output is correct
10 Correct 67 ms 1092 KB Output is correct
11 Correct 8 ms 348 KB Output is correct
12 Correct 55 ms 932 KB Output is correct
13 Correct 46 ms 860 KB Output is correct
14 Correct 52 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 1004 KB Output is correct
2 Correct 432 ms 860 KB Output is correct
3 Correct 105 ms 1004 KB Output is correct
4 Correct 63 ms 1000 KB Output is correct
5 Correct 37 ms 940 KB Output is correct
6 Correct 61 ms 860 KB Output is correct
7 Correct 56 ms 848 KB Output is correct
8 Correct 80 ms 956 KB Output is correct
9 Correct 75 ms 1144 KB Output is correct
10 Correct 67 ms 1092 KB Output is correct
11 Correct 8 ms 348 KB Output is correct
12 Correct 55 ms 932 KB Output is correct
13 Correct 46 ms 860 KB Output is correct
14 Correct 52 ms 860 KB Output is correct
15 Correct 167 ms 1008 KB Output is correct
16 Correct 59 ms 1072 KB Output is correct
17 Correct 83 ms 1120 KB Output is correct
18 Correct 65 ms 1112 KB Output is correct
19 Correct 67 ms 1116 KB Output is correct
20 Correct 65 ms 1116 KB Output is correct
21 Correct 66 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 8 ms 564 KB Output is correct
14 Correct 6 ms 600 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 5 ms 604 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 292 ms 1004 KB Output is correct
20 Correct 432 ms 860 KB Output is correct
21 Correct 105 ms 1004 KB Output is correct
22 Correct 63 ms 1000 KB Output is correct
23 Correct 37 ms 940 KB Output is correct
24 Correct 61 ms 860 KB Output is correct
25 Correct 56 ms 848 KB Output is correct
26 Correct 80 ms 956 KB Output is correct
27 Correct 75 ms 1144 KB Output is correct
28 Correct 67 ms 1092 KB Output is correct
29 Correct 8 ms 348 KB Output is correct
30 Correct 55 ms 932 KB Output is correct
31 Correct 46 ms 860 KB Output is correct
32 Correct 52 ms 860 KB Output is correct
33 Correct 167 ms 1008 KB Output is correct
34 Correct 59 ms 1072 KB Output is correct
35 Correct 83 ms 1120 KB Output is correct
36 Correct 65 ms 1112 KB Output is correct
37 Correct 67 ms 1116 KB Output is correct
38 Correct 65 ms 1116 KB Output is correct
39 Correct 66 ms 1116 KB Output is correct
40 Correct 492 ms 2104 KB Output is correct
41 Correct 13 ms 600 KB Output is correct
42 Correct 103 ms 2108 KB Output is correct
43 Correct 73 ms 1644 KB Output is correct
44 Correct 75 ms 1872 KB Output is correct
45 Correct 567 ms 6732 KB Output is correct
46 Correct 17 ms 1116 KB Output is correct
47 Correct 249 ms 6720 KB Output is correct
48 Correct 117 ms 4792 KB Output is correct
49 Correct 121 ms 5456 KB Output is correct