Submission #95197

# Submission time Handle Problem Language Result Execution time Memory
95197 2019-01-28T13:15:57 Z onjo0127 Lottery (CEOI18_lot) C++11
100 / 100
499 ms 8488 KB
#include <bits/stdc++.h>
using namespace std;

int A[10009], K[111], ch[10009], D[10009][111];

int main() {
    int l, N; scanf("%d%d",&N,&l);
    for(int i=1; i<=N; i++) scanf("%d",&A[i]);
    vector<int> S;
    int Q; scanf("%d",&Q);
    for(int i=1; i<=Q; i++) {
        scanf("%d",&K[i]);
        S.push_back(K[i]);
    } S.push_back(1e9);
    sort(S.begin(), S.end()); S.resize(unique(S.begin(), S.end()) - S.begin());
    for(int i=0; i<=l; i++) ch[i] = (int)S.size() - 1;
    for(int i=0, j=0; i<(int)S.size()-1; i++) {
        while(j <= S[i]) ch[j++] = i;
    }
    for(int i=1; i<=N-l; i++) {
        int s = 0;
        for(int j=1; j<=l; j++) s += (A[j] != A[j+i]);
        for(int j=1; j+i+l-1<=N; j++) {
            ++D[j][ch[s]]; ++D[j+i][ch[s]];
            s -= (A[j] != A[j+i]);
            s += (A[j+l] != A[j+i+l]);
        }
    }
    for(int i=1; i<=N-l+1; i++) for(int j=0, s=0; j<=Q; j++) s += D[i][j], D[i][j] = s;
    for(int i=1; i<=Q; i++) {
        int x = lower_bound(S.begin(), S.end(), K[i]) - S.begin();
        for(int j=1; j<=N-l+1; j++) printf("%d ",D[j][x]);
        puts("");
    }
    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int l, N; scanf("%d%d",&N,&l);
               ~~~~~^~~~~~~~~~~~~~
lot.cpp:8:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=N; i++) scanf("%d",&A[i]);
                             ~~~~~^~~~~~~~~~~~
lot.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int Q; scanf("%d",&Q);
            ~~~~~^~~~~~~~~
lot.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&K[i]);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 13 ms 1272 KB Output is correct
14 Correct 9 ms 1016 KB Output is correct
15 Correct 8 ms 1016 KB Output is correct
16 Correct 13 ms 1148 KB Output is correct
17 Correct 12 ms 1144 KB Output is correct
18 Correct 12 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 4748 KB Output is correct
2 Correct 425 ms 4728 KB Output is correct
3 Correct 380 ms 4728 KB Output is correct
4 Correct 373 ms 4856 KB Output is correct
5 Correct 100 ms 2680 KB Output is correct
6 Correct 315 ms 4472 KB Output is correct
7 Correct 99 ms 2680 KB Output is correct
8 Correct 193 ms 3704 KB Output is correct
9 Correct 426 ms 4728 KB Output is correct
10 Correct 403 ms 4776 KB Output is correct
11 Correct 14 ms 1272 KB Output is correct
12 Correct 187 ms 3448 KB Output is correct
13 Correct 146 ms 3072 KB Output is correct
14 Correct 149 ms 3112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 4748 KB Output is correct
2 Correct 425 ms 4728 KB Output is correct
3 Correct 380 ms 4728 KB Output is correct
4 Correct 373 ms 4856 KB Output is correct
5 Correct 100 ms 2680 KB Output is correct
6 Correct 315 ms 4472 KB Output is correct
7 Correct 99 ms 2680 KB Output is correct
8 Correct 193 ms 3704 KB Output is correct
9 Correct 426 ms 4728 KB Output is correct
10 Correct 403 ms 4776 KB Output is correct
11 Correct 14 ms 1272 KB Output is correct
12 Correct 187 ms 3448 KB Output is correct
13 Correct 146 ms 3072 KB Output is correct
14 Correct 149 ms 3112 KB Output is correct
15 Correct 366 ms 4612 KB Output is correct
16 Correct 338 ms 4344 KB Output is correct
17 Correct 368 ms 4956 KB Output is correct
18 Correct 353 ms 4824 KB Output is correct
19 Correct 371 ms 4728 KB Output is correct
20 Correct 370 ms 4728 KB Output is correct
21 Correct 352 ms 4856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 13 ms 1272 KB Output is correct
14 Correct 9 ms 1016 KB Output is correct
15 Correct 8 ms 1016 KB Output is correct
16 Correct 13 ms 1148 KB Output is correct
17 Correct 12 ms 1144 KB Output is correct
18 Correct 12 ms 1144 KB Output is correct
19 Correct 347 ms 4748 KB Output is correct
20 Correct 425 ms 4728 KB Output is correct
21 Correct 380 ms 4728 KB Output is correct
22 Correct 373 ms 4856 KB Output is correct
23 Correct 100 ms 2680 KB Output is correct
24 Correct 315 ms 4472 KB Output is correct
25 Correct 99 ms 2680 KB Output is correct
26 Correct 193 ms 3704 KB Output is correct
27 Correct 426 ms 4728 KB Output is correct
28 Correct 403 ms 4776 KB Output is correct
29 Correct 14 ms 1272 KB Output is correct
30 Correct 187 ms 3448 KB Output is correct
31 Correct 146 ms 3072 KB Output is correct
32 Correct 149 ms 3112 KB Output is correct
33 Correct 366 ms 4612 KB Output is correct
34 Correct 338 ms 4344 KB Output is correct
35 Correct 368 ms 4956 KB Output is correct
36 Correct 353 ms 4824 KB Output is correct
37 Correct 371 ms 4728 KB Output is correct
38 Correct 370 ms 4728 KB Output is correct
39 Correct 352 ms 4856 KB Output is correct
40 Correct 404 ms 5524 KB Output is correct
41 Correct 13 ms 1016 KB Output is correct
42 Correct 408 ms 5624 KB Output is correct
43 Correct 330 ms 5064 KB Output is correct
44 Correct 357 ms 5160 KB Output is correct
45 Correct 437 ms 8428 KB Output is correct
46 Correct 37 ms 1292 KB Output is correct
47 Correct 430 ms 8488 KB Output is correct
48 Correct 499 ms 6776 KB Output is correct
49 Correct 411 ms 7376 KB Output is correct