Submission #307475

# Submission time Handle Problem Language Result Execution time Memory
307475 2020-09-28T09:02:38 Z keta_tsimakuridze Lottery (CEOI18_lot) C++14
100 / 100
887 ms 8440 KB
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 1e4+5;
int n , l , q , a[N] , b[N] , cur , ans[N][105]  , aft[N],ind[105];
pair< int , int > p[105];
int main() {
	cin>>n>>l;
	for(int k=1; k<=n; k++)
		cin>>a[k];
	cin>>q;
	for(int k=1; k<=q; k++) {
		cin>>p[k].f;
		p[k].s=k;
	}
	//k___l
	// k-ze meti an toli
	sort(p+1,p+q+1);
	cur=1;
	for(int k=0; k<=n; k++){
		while(p[cur].f<k && cur<=q) {
			cur++;
		}
		aft[k]=cur;
	}

	for(int d=1; d<=n; d++) {
		for(int k=1; k<=n-d; k++) {
			b[k]=0;
			if(a[k]!=a[k+d]){
				b[k]=1;
			}
		}
		for(int k=1; k<=n-d; k++){
			
		//	cout<<b[k]<<" ";
			b[k]+=b[k-1];
			if( k>=l ){
				int K=b[k]-b[k-l];
				ans[k-l+1][aft[K]]++;
				ans[k+d-l+1][aft[K]]++;
			}
		}
	}
	for(int k=1; k<=q; k++){
		ind[p[k].s]=k;
		for(int i=1; i<=n-l+1; i++){
			ans[i][k]=ans[i][k]+ans[i][k-1];
		}
	}
	
	for(int k=1; k<=q; k++){
	
		for(int i=1; i<=n-l+1; i++){
			cout<<ans[i][ind[k]]<<" ";
		}
		cout<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 24 ms 1272 KB Output is correct
14 Correct 18 ms 1024 KB Output is correct
15 Correct 18 ms 1016 KB Output is correct
16 Correct 23 ms 1272 KB Output is correct
17 Correct 21 ms 1152 KB Output is correct
18 Correct 21 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 759 ms 4600 KB Output is correct
2 Correct 743 ms 4728 KB Output is correct
3 Correct 549 ms 4728 KB Output is correct
4 Correct 490 ms 4728 KB Output is correct
5 Correct 281 ms 2680 KB Output is correct
6 Correct 462 ms 4472 KB Output is correct
7 Correct 280 ms 2680 KB Output is correct
8 Correct 354 ms 3704 KB Output is correct
9 Correct 483 ms 4600 KB Output is correct
10 Correct 489 ms 4728 KB Output is correct
11 Correct 35 ms 1152 KB Output is correct
12 Correct 329 ms 3448 KB Output is correct
13 Correct 321 ms 3008 KB Output is correct
14 Correct 324 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 759 ms 4600 KB Output is correct
2 Correct 743 ms 4728 KB Output is correct
3 Correct 549 ms 4728 KB Output is correct
4 Correct 490 ms 4728 KB Output is correct
5 Correct 281 ms 2680 KB Output is correct
6 Correct 462 ms 4472 KB Output is correct
7 Correct 280 ms 2680 KB Output is correct
8 Correct 354 ms 3704 KB Output is correct
9 Correct 483 ms 4600 KB Output is correct
10 Correct 489 ms 4728 KB Output is correct
11 Correct 35 ms 1152 KB Output is correct
12 Correct 329 ms 3448 KB Output is correct
13 Correct 321 ms 3008 KB Output is correct
14 Correct 324 ms 3012 KB Output is correct
15 Correct 531 ms 4480 KB Output is correct
16 Correct 443 ms 4344 KB Output is correct
17 Correct 509 ms 4680 KB Output is correct
18 Correct 502 ms 4608 KB Output is correct
19 Correct 513 ms 4608 KB Output is correct
20 Correct 500 ms 4728 KB Output is correct
21 Correct 495 ms 4728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 24 ms 1272 KB Output is correct
14 Correct 18 ms 1024 KB Output is correct
15 Correct 18 ms 1016 KB Output is correct
16 Correct 23 ms 1272 KB Output is correct
17 Correct 21 ms 1152 KB Output is correct
18 Correct 21 ms 1152 KB Output is correct
19 Correct 759 ms 4600 KB Output is correct
20 Correct 743 ms 4728 KB Output is correct
21 Correct 549 ms 4728 KB Output is correct
22 Correct 490 ms 4728 KB Output is correct
23 Correct 281 ms 2680 KB Output is correct
24 Correct 462 ms 4472 KB Output is correct
25 Correct 280 ms 2680 KB Output is correct
26 Correct 354 ms 3704 KB Output is correct
27 Correct 483 ms 4600 KB Output is correct
28 Correct 489 ms 4728 KB Output is correct
29 Correct 35 ms 1152 KB Output is correct
30 Correct 329 ms 3448 KB Output is correct
31 Correct 321 ms 3008 KB Output is correct
32 Correct 324 ms 3012 KB Output is correct
33 Correct 531 ms 4480 KB Output is correct
34 Correct 443 ms 4344 KB Output is correct
35 Correct 509 ms 4680 KB Output is correct
36 Correct 502 ms 4608 KB Output is correct
37 Correct 513 ms 4608 KB Output is correct
38 Correct 500 ms 4728 KB Output is correct
39 Correct 495 ms 4728 KB Output is correct
40 Correct 772 ms 5340 KB Output is correct
41 Correct 219 ms 1016 KB Output is correct
42 Correct 523 ms 5368 KB Output is correct
43 Correct 490 ms 4856 KB Output is correct
44 Correct 493 ms 5020 KB Output is correct
45 Correct 887 ms 8440 KB Output is correct
46 Correct 230 ms 1276 KB Output is correct
47 Correct 603 ms 8440 KB Output is correct
48 Correct 564 ms 6520 KB Output is correct
49 Correct 567 ms 7288 KB Output is correct