답안 #1000587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000587 2024-06-17T22:03:08 Z codefox Lottery (CEOI18_lot) C++14
100 / 100
255 ms 8680 KB
#include<bits/stdc++.h>

using namespace std;

#define pii pair<int, int>

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, l;
    cin >> n >> l;
    map<int, int> nn;
    vector<int> nums(n);
    vector<vector<int>> ns(n+1);
    int d=0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (nn[a]==0) nn[a] = ++d;
        nums[i] = nn[a];
        ns[nn[a]].push_back(i);
    }
    int q;
    cin >> q;
    vector<int> qs(q);
    vector<vector<int>> ans(q, vector<int>(n-l+1, 0));

    for (int i = 0; i < q; i++) cin >> qs[i];

    vector<int> inter(2*n, 0);

    int r = 0;
    for (int i = 0; i <= n-l; i++)
    {
        if (i)
        {
            for (int ele:ns[nums[i-1]])
            {
                inter[ele-i+1+n]--;
            }
        }
        while (r-i < l)
        {
            for (int ele:ns[nums[r]])
            {
                inter[ele-r+n]++;
            }
            r++;
        }
        vector<int> qqs(n+1, 0);
        for (int j = n-i; j < n+n-i-l+1; j++) qqs[inter[j]]++;
        for (int j = n-1; j >=0; j--) qqs[j] += qqs[j+1];
        for (int j = 0; j < q; j++)
        {
            ans[j][i] = qqs[l-qs[j]]-1;
        }
    }
    for (auto ele:ans) 
    {
        for (int ele2:ele) cout << ele2 << " ";
        cout << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 10 ms 600 KB Output is correct
14 Correct 5 ms 824 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 10 ms 692 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 7 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 214 ms 988 KB Output is correct
2 Correct 205 ms 856 KB Output is correct
3 Correct 239 ms 856 KB Output is correct
4 Correct 148 ms 860 KB Output is correct
5 Correct 126 ms 1012 KB Output is correct
6 Correct 120 ms 1368 KB Output is correct
7 Correct 147 ms 992 KB Output is correct
8 Correct 179 ms 860 KB Output is correct
9 Correct 197 ms 964 KB Output is correct
10 Correct 196 ms 1108 KB Output is correct
11 Correct 10 ms 620 KB Output is correct
12 Correct 77 ms 1248 KB Output is correct
13 Correct 115 ms 1112 KB Output is correct
14 Correct 100 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 214 ms 988 KB Output is correct
2 Correct 205 ms 856 KB Output is correct
3 Correct 239 ms 856 KB Output is correct
4 Correct 148 ms 860 KB Output is correct
5 Correct 126 ms 1012 KB Output is correct
6 Correct 120 ms 1368 KB Output is correct
7 Correct 147 ms 992 KB Output is correct
8 Correct 179 ms 860 KB Output is correct
9 Correct 197 ms 964 KB Output is correct
10 Correct 196 ms 1108 KB Output is correct
11 Correct 10 ms 620 KB Output is correct
12 Correct 77 ms 1248 KB Output is correct
13 Correct 115 ms 1112 KB Output is correct
14 Correct 100 ms 1116 KB Output is correct
15 Correct 115 ms 988 KB Output is correct
16 Correct 247 ms 856 KB Output is correct
17 Correct 188 ms 1116 KB Output is correct
18 Correct 120 ms 964 KB Output is correct
19 Correct 115 ms 1116 KB Output is correct
20 Correct 156 ms 1116 KB Output is correct
21 Correct 155 ms 1136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 436 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 10 ms 600 KB Output is correct
14 Correct 5 ms 824 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 10 ms 692 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 7 ms 604 KB Output is correct
19 Correct 214 ms 988 KB Output is correct
20 Correct 205 ms 856 KB Output is correct
21 Correct 239 ms 856 KB Output is correct
22 Correct 148 ms 860 KB Output is correct
23 Correct 126 ms 1012 KB Output is correct
24 Correct 120 ms 1368 KB Output is correct
25 Correct 147 ms 992 KB Output is correct
26 Correct 179 ms 860 KB Output is correct
27 Correct 197 ms 964 KB Output is correct
28 Correct 196 ms 1108 KB Output is correct
29 Correct 10 ms 620 KB Output is correct
30 Correct 77 ms 1248 KB Output is correct
31 Correct 115 ms 1112 KB Output is correct
32 Correct 100 ms 1116 KB Output is correct
33 Correct 115 ms 988 KB Output is correct
34 Correct 247 ms 856 KB Output is correct
35 Correct 188 ms 1116 KB Output is correct
36 Correct 120 ms 964 KB Output is correct
37 Correct 115 ms 1116 KB Output is correct
38 Correct 156 ms 1116 KB Output is correct
39 Correct 155 ms 1136 KB Output is correct
40 Correct 219 ms 2496 KB Output is correct
41 Correct 21 ms 1108 KB Output is correct
42 Correct 218 ms 2524 KB Output is correct
43 Correct 116 ms 2128 KB Output is correct
44 Correct 125 ms 2128 KB Output is correct
45 Correct 227 ms 8532 KB Output is correct
46 Correct 26 ms 1620 KB Output is correct
47 Correct 255 ms 8680 KB Output is correct
48 Correct 162 ms 6764 KB Output is correct
49 Correct 167 ms 7400 KB Output is correct