# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
128165 | 2019-07-10T13:27:22 Z | TadijaSebez | Lottery (CEOI18_lot) | C++11 | 777 ms | 8492 KB |
#include <bits/stdc++.h> using namespace std; const int N=10050; const int K=105; int dp[2][N],a[N],k[K],ans[K][N],cnt[N],n,l,q,m; void Solve(int x, int t) { for(int i=0;i<=l;i++) cnt[i]=0; for(int i=1;i<=m;i++) if(i!=x) cnt[dp[t][i]]++; for(int i=1;i<=l;i++) cnt[i]+=cnt[i-1]; for(int i=1;i<=q;i++) ans[i][x]=cnt[k[i]]; } int main() { scanf("%i %i",&n,&l); for(int i=1;i<=n;i++) scanf("%i",&a[i]); scanf("%i",&q); for(int i=1;i<=q;i++) scanf("%i",&k[i]); m=n-l+1; for(int i=1;i<=m;i++) for(int j=0;j<l;j++) dp[0][i]+=a[1+j]!=a[i+j]; Solve(1,0); int t=1; for(int i=2;i<=m;i++) { for(int j=1;j<=m;j++) dp[t][j]=0; for(int j=0;j<l;j++) dp[t][1]+=a[1+j]!=a[i+j]; for(int j=2;j<=m;j++) { dp[t][j]=dp[t^1][j-1]; dp[t][j]-=a[i-1]!=a[j-1]; dp[t][j]+=a[i+l-1]!=a[j+l-1]; } Solve(i,t); t^=1; } for(int i=1;i<=q;i++) for(int j=1;j<=m;j++) printf("%i%c",ans[i][j],j==m?'\n':' '); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 532 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 3 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 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 | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 532 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 3 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 25 ms | 504 KB | Output is correct |
14 | Correct | 19 ms | 632 KB | Output is correct |
15 | Correct | 18 ms | 504 KB | Output is correct |
16 | Correct | 26 ms | 632 KB | Output is correct |
17 | Correct | 24 ms | 632 KB | Output is correct |
18 | Correct | 24 ms | 632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 552 ms | 668 KB | Output is correct |
2 | Correct | 551 ms | 632 KB | Output is correct |
3 | Correct | 560 ms | 648 KB | Output is correct |
4 | Correct | 545 ms | 608 KB | Output is correct |
5 | Correct | 266 ms | 832 KB | Output is correct |
6 | Correct | 516 ms | 632 KB | Output is correct |
7 | Correct | 263 ms | 504 KB | Output is correct |
8 | Correct | 379 ms | 636 KB | Output is correct |
9 | Correct | 540 ms | 632 KB | Output is correct |
10 | Correct | 547 ms | 636 KB | Output is correct |
11 | Correct | 34 ms | 376 KB | Output is correct |
12 | Correct | 345 ms | 632 KB | Output is correct |
13 | Correct | 317 ms | 632 KB | Output is correct |
14 | Correct | 319 ms | 708 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 552 ms | 668 KB | Output is correct |
2 | Correct | 551 ms | 632 KB | Output is correct |
3 | Correct | 560 ms | 648 KB | Output is correct |
4 | Correct | 545 ms | 608 KB | Output is correct |
5 | Correct | 266 ms | 832 KB | Output is correct |
6 | Correct | 516 ms | 632 KB | Output is correct |
7 | Correct | 263 ms | 504 KB | Output is correct |
8 | Correct | 379 ms | 636 KB | Output is correct |
9 | Correct | 540 ms | 632 KB | Output is correct |
10 | Correct | 547 ms | 636 KB | Output is correct |
11 | Correct | 34 ms | 376 KB | Output is correct |
12 | Correct | 345 ms | 632 KB | Output is correct |
13 | Correct | 317 ms | 632 KB | Output is correct |
14 | Correct | 319 ms | 708 KB | Output is correct |
15 | Correct | 534 ms | 652 KB | Output is correct |
16 | Correct | 496 ms | 728 KB | Output is correct |
17 | Correct | 558 ms | 632 KB | Output is correct |
18 | Correct | 565 ms | 632 KB | Output is correct |
19 | Correct | 564 ms | 604 KB | Output is correct |
20 | Correct | 555 ms | 728 KB | Output is correct |
21 | Correct | 553 ms | 760 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 | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 532 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 3 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 25 ms | 504 KB | Output is correct |
14 | Correct | 19 ms | 632 KB | Output is correct |
15 | Correct | 18 ms | 504 KB | Output is correct |
16 | Correct | 26 ms | 632 KB | Output is correct |
17 | Correct | 24 ms | 632 KB | Output is correct |
18 | Correct | 24 ms | 632 KB | Output is correct |
19 | Correct | 552 ms | 668 KB | Output is correct |
20 | Correct | 551 ms | 632 KB | Output is correct |
21 | Correct | 560 ms | 648 KB | Output is correct |
22 | Correct | 545 ms | 608 KB | Output is correct |
23 | Correct | 266 ms | 832 KB | Output is correct |
24 | Correct | 516 ms | 632 KB | Output is correct |
25 | Correct | 263 ms | 504 KB | Output is correct |
26 | Correct | 379 ms | 636 KB | Output is correct |
27 | Correct | 540 ms | 632 KB | Output is correct |
28 | Correct | 547 ms | 636 KB | Output is correct |
29 | Correct | 34 ms | 376 KB | Output is correct |
30 | Correct | 345 ms | 632 KB | Output is correct |
31 | Correct | 317 ms | 632 KB | Output is correct |
32 | Correct | 319 ms | 708 KB | Output is correct |
33 | Correct | 534 ms | 652 KB | Output is correct |
34 | Correct | 496 ms | 728 KB | Output is correct |
35 | Correct | 558 ms | 632 KB | Output is correct |
36 | Correct | 565 ms | 632 KB | Output is correct |
37 | Correct | 564 ms | 604 KB | Output is correct |
38 | Correct | 555 ms | 728 KB | Output is correct |
39 | Correct | 553 ms | 760 KB | Output is correct |
40 | Correct | 575 ms | 2164 KB | Output is correct |
41 | Correct | 59 ms | 760 KB | Output is correct |
42 | Correct | 597 ms | 2068 KB | Output is correct |
43 | Correct | 777 ms | 1932 KB | Output is correct |
44 | Correct | 567 ms | 1936 KB | Output is correct |
45 | Correct | 691 ms | 8264 KB | Output is correct |
46 | Correct | 72 ms | 1704 KB | Output is correct |
47 | Correct | 688 ms | 8492 KB | Output is correct |
48 | Correct | 667 ms | 6856 KB | Output is correct |
49 | Correct | 664 ms | 7352 KB | Output is correct |