Submission #950193

# Submission time Handle Problem Language Result Execution time Memory
950193 2024-03-20T06:45:37 Z berr Lottery (CEOI18_lot) C++17
100 / 100
761 ms 8660 KB
#include <bits/stdc++.h>
using namespace std;


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int len, n; cin >> n >> len;
    vector<int> ar(n);

    for(auto &i: ar) cin >> i;

    int q; cin >> q;
    vector<array<int, 2>> qu(q);

    for(int i=0; i<q; i++){
        cin >> qu[i][0];
        qu[i][1] = i;
    }

    sort(qu.begin(), qu.end());

    int sum=0;
    vector<vector<int>> a(n, vector<int>(q, 0));

    auto calc=[&](int pos){
        int l=0, r=pos;
        int ans=0, ind=0;
        if(pos+l-1>=n) return;
        for(int j=0; j+pos<n; j++){
            if(ar[j]!=ar[j+pos]) ans++;
            if(j-len>=0){
                ans-=(ar[j-len]!=ar[j-len+pos]);
            }   

          //  cout<<ans<<"\n";

            while(ind<q-1 && ans>qu[ind][0]) ind++;
            while(ind>0 && ans <= qu[ind-1][0]) ind--;

            if(j>=len-1){
                if(ans>qu[ind][0]){
                    l++; r++;
                    continue;
                }
                a[l][ind]++;
                a[r][ind]++;
                l++; r++;
            }

        }
    };

    for(int i=1; i<n; i++){
        calc(i);
    }   
    vector<int> pos(q);

    for(int i=0; i<q; i++){
        pos[qu[i][1]]=i;
    }

    for(int i=0; i<n; i++){
        for(int j=1; j<q; j++){
            a[i][j] += a[i][j-1];
        }

    }
    for(int j=0; j<q; j++){
        for(int i=0; i+len-1<n; i++){
            cout<<a[i][pos[j]]<<" ";
        }
        cout<<"\n";
    }


}   

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:25:9: warning: unused variable 'sum' [-Wunused-variable]
   25 |     int sum=0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 448 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 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 448 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 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 11 ms 604 KB Output is correct
14 Correct 9 ms 720 KB Output is correct
15 Correct 7 ms 600 KB Output is correct
16 Correct 9 ms 604 KB Output is correct
17 Correct 8 ms 604 KB Output is correct
18 Correct 9 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 358 ms 1048 KB Output is correct
2 Correct 348 ms 1068 KB Output is correct
3 Correct 190 ms 1104 KB Output is correct
4 Correct 140 ms 1148 KB Output is correct
5 Correct 104 ms 1136 KB Output is correct
6 Correct 152 ms 1136 KB Output is correct
7 Correct 128 ms 1152 KB Output is correct
8 Correct 145 ms 1112 KB Output is correct
9 Correct 156 ms 1112 KB Output is correct
10 Correct 143 ms 1136 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 102 ms 860 KB Output is correct
13 Correct 110 ms 1116 KB Output is correct
14 Correct 117 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 358 ms 1048 KB Output is correct
2 Correct 348 ms 1068 KB Output is correct
3 Correct 190 ms 1104 KB Output is correct
4 Correct 140 ms 1148 KB Output is correct
5 Correct 104 ms 1136 KB Output is correct
6 Correct 152 ms 1136 KB Output is correct
7 Correct 128 ms 1152 KB Output is correct
8 Correct 145 ms 1112 KB Output is correct
9 Correct 156 ms 1112 KB Output is correct
10 Correct 143 ms 1136 KB Output is correct
11 Correct 14 ms 604 KB Output is correct
12 Correct 102 ms 860 KB Output is correct
13 Correct 110 ms 1116 KB Output is correct
14 Correct 117 ms 1136 KB Output is correct
15 Correct 207 ms 1052 KB Output is correct
16 Correct 130 ms 1132 KB Output is correct
17 Correct 168 ms 1132 KB Output is correct
18 Correct 139 ms 1144 KB Output is correct
19 Correct 140 ms 1144 KB Output is correct
20 Correct 149 ms 1136 KB Output is correct
21 Correct 149 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 448 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 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 11 ms 604 KB Output is correct
14 Correct 9 ms 720 KB Output is correct
15 Correct 7 ms 600 KB Output is correct
16 Correct 9 ms 604 KB Output is correct
17 Correct 8 ms 604 KB Output is correct
18 Correct 9 ms 604 KB Output is correct
19 Correct 358 ms 1048 KB Output is correct
20 Correct 348 ms 1068 KB Output is correct
21 Correct 190 ms 1104 KB Output is correct
22 Correct 140 ms 1148 KB Output is correct
23 Correct 104 ms 1136 KB Output is correct
24 Correct 152 ms 1136 KB Output is correct
25 Correct 128 ms 1152 KB Output is correct
26 Correct 145 ms 1112 KB Output is correct
27 Correct 156 ms 1112 KB Output is correct
28 Correct 143 ms 1136 KB Output is correct
29 Correct 14 ms 604 KB Output is correct
30 Correct 102 ms 860 KB Output is correct
31 Correct 110 ms 1116 KB Output is correct
32 Correct 117 ms 1136 KB Output is correct
33 Correct 207 ms 1052 KB Output is correct
34 Correct 130 ms 1132 KB Output is correct
35 Correct 168 ms 1132 KB Output is correct
36 Correct 139 ms 1144 KB Output is correct
37 Correct 140 ms 1144 KB Output is correct
38 Correct 149 ms 1136 KB Output is correct
39 Correct 149 ms 1132 KB Output is correct
40 Correct 503 ms 2444 KB Output is correct
41 Correct 130 ms 1760 KB Output is correct
42 Correct 186 ms 2388 KB Output is correct
43 Correct 179 ms 2116 KB Output is correct
44 Correct 173 ms 2272 KB Output is correct
45 Correct 761 ms 8652 KB Output is correct
46 Correct 129 ms 5200 KB Output is correct
47 Correct 284 ms 8660 KB Output is correct
48 Correct 228 ms 6816 KB Output is correct
49 Correct 229 ms 7448 KB Output is correct