답안 #126005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126005 2019-07-06T17:34:16 Z Hassoony Lottery (CEOI18_lot) C++17
100 / 100
814 ms 8696 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=10009;
int n,l,a[MX],id[109];
pair<int,int> k[109];
int ans[MX][109];
int col[MX],p[MX];
int where[MX],ans1[MX][109],q;
int main(){
    cin>>n>>l;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    cin>>q;
    for(int i=1;i<=q;i++){
        scanf("%d",&k[i].first);
        k[i].second=i;
    }
    for(int i=0;i<=l;i++)where[i]=q+1;
    sort(k+1,k+1+q);
    for(int i=1;i<=q;i++){
        id[k[i].second]=i;
    }
    for(int i=0;i<=l;i++){
        for(int j=1;j<=q;j++){
            if(k[j].first>=i){
                where[i]=j;
                break;
            }
        }
    }
    for(int j=1;j<=(n-l+1);j++){
        for(int i=1;i<MX;i++)col[i]=p[i]=0;
        for(int i=1;i+j<=n;i++){
            col[i]=(a[i]!=a[i+j]);
            p[i]=p[i-1]+col[i];
        }
        for(int i=1;i+j+l-1<=n;i++){
            ans[i][where[p[i+l-1]-p[i-1]]]++;
            ans[i+j][where[p[i+l-1]-p[i-1]]]++;
        }
    }
    for(int i=1;i<=n-l+1;i++){
        for(int j=1;j<=q;j++){
            ans[i][j]+=ans[i][j-1];
        }
    }
    for(int i=1;i<=q;i++){
        for(int j=1;j<=n-l+1;j++)cout<<ans[j][id[i]]<<" ";
        puts("");
    }
}
/*
6 2
1 2 1 3 2 1
2
1
2
*/

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
         ~~~~~^~~~~~~~~~~~
lot.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k[i].first);
         ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 7 ms 632 KB Output is correct
11 Correct 7 ms 504 KB Output is correct
12 Correct 6 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 7 ms 632 KB Output is correct
11 Correct 7 ms 504 KB Output is correct
12 Correct 6 ms 632 KB Output is correct
13 Correct 52 ms 1400 KB Output is correct
14 Correct 34 ms 1144 KB Output is correct
15 Correct 32 ms 1016 KB Output is correct
16 Correct 47 ms 1272 KB Output is correct
17 Correct 43 ms 1244 KB Output is correct
18 Correct 43 ms 1192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 697 ms 4780 KB Output is correct
2 Correct 696 ms 4856 KB Output is correct
3 Correct 680 ms 4732 KB Output is correct
4 Correct 664 ms 4772 KB Output is correct
5 Correct 282 ms 2808 KB Output is correct
6 Correct 616 ms 4472 KB Output is correct
7 Correct 278 ms 2808 KB Output is correct
8 Correct 426 ms 3576 KB Output is correct
9 Correct 655 ms 4708 KB Output is correct
10 Correct 668 ms 4728 KB Output is correct
11 Correct 54 ms 1372 KB Output is correct
12 Correct 404 ms 3448 KB Output is correct
13 Correct 342 ms 3192 KB Output is correct
14 Correct 352 ms 3128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 697 ms 4780 KB Output is correct
2 Correct 696 ms 4856 KB Output is correct
3 Correct 680 ms 4732 KB Output is correct
4 Correct 664 ms 4772 KB Output is correct
5 Correct 282 ms 2808 KB Output is correct
6 Correct 616 ms 4472 KB Output is correct
7 Correct 278 ms 2808 KB Output is correct
8 Correct 426 ms 3576 KB Output is correct
9 Correct 655 ms 4708 KB Output is correct
10 Correct 668 ms 4728 KB Output is correct
11 Correct 54 ms 1372 KB Output is correct
12 Correct 404 ms 3448 KB Output is correct
13 Correct 342 ms 3192 KB Output is correct
14 Correct 352 ms 3128 KB Output is correct
15 Correct 663 ms 4636 KB Output is correct
16 Correct 600 ms 4472 KB Output is correct
17 Correct 690 ms 4848 KB Output is correct
18 Correct 673 ms 4728 KB Output is correct
19 Correct 693 ms 4728 KB Output is correct
20 Correct 669 ms 4856 KB Output is correct
21 Correct 676 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 7 ms 632 KB Output is correct
11 Correct 7 ms 504 KB Output is correct
12 Correct 6 ms 632 KB Output is correct
13 Correct 52 ms 1400 KB Output is correct
14 Correct 34 ms 1144 KB Output is correct
15 Correct 32 ms 1016 KB Output is correct
16 Correct 47 ms 1272 KB Output is correct
17 Correct 43 ms 1244 KB Output is correct
18 Correct 43 ms 1192 KB Output is correct
19 Correct 697 ms 4780 KB Output is correct
20 Correct 696 ms 4856 KB Output is correct
21 Correct 680 ms 4732 KB Output is correct
22 Correct 664 ms 4772 KB Output is correct
23 Correct 282 ms 2808 KB Output is correct
24 Correct 616 ms 4472 KB Output is correct
25 Correct 278 ms 2808 KB Output is correct
26 Correct 426 ms 3576 KB Output is correct
27 Correct 655 ms 4708 KB Output is correct
28 Correct 668 ms 4728 KB Output is correct
29 Correct 54 ms 1372 KB Output is correct
30 Correct 404 ms 3448 KB Output is correct
31 Correct 342 ms 3192 KB Output is correct
32 Correct 352 ms 3128 KB Output is correct
33 Correct 663 ms 4636 KB Output is correct
34 Correct 600 ms 4472 KB Output is correct
35 Correct 690 ms 4848 KB Output is correct
36 Correct 673 ms 4728 KB Output is correct
37 Correct 693 ms 4728 KB Output is correct
38 Correct 669 ms 4856 KB Output is correct
39 Correct 676 ms 4856 KB Output is correct
40 Correct 712 ms 5504 KB Output is correct
41 Correct 49 ms 1016 KB Output is correct
42 Correct 695 ms 5496 KB Output is correct
43 Correct 675 ms 5112 KB Output is correct
44 Correct 689 ms 5084 KB Output is correct
45 Correct 801 ms 8568 KB Output is correct
46 Correct 58 ms 1272 KB Output is correct
47 Correct 814 ms 8696 KB Output is correct
48 Correct 754 ms 6744 KB Output is correct
49 Correct 770 ms 7416 KB Output is correct