Submission #823360

# Submission time Handle Problem Language Result Execution time Memory
823360 2023-08-12T11:25:00 Z MohamedAhmed04 Lottery (CEOI18_lot) C++14
100 / 100
1055 ms 8692 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e4 + 10 ;

int arr[MAX] , ans[MAX][110] , Cnt[MAX] , pref[MAX] ;
int Q[MAX] , Q2[MAX] ;
int n , l , q ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>l ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	cin>>q ;
	for(int i = 0 ; i < q ; ++i)
	{
		cin>>Q[i] ;
		Q2[i] = Q[i] ;
	}
	sort(Q , Q + q) ;
	for(int j = 1 ; j < n ; ++j) // distance
	{
		pref[0] = 0 ;
		for(int i = 0 ; i+j < n ; ++i)
		{
			if(i)
				pref[i] = pref[i-1] ;
			if(arr[i] != arr[i+j])
				pref[i]++ ;
		}
		for(int i = 0 ; i+j+l-1 < n ; ++i)
		{
			int x = pref[i+l-1] ;
			if(i)
				x -= pref[i-1] ;
			int idx = lower_bound(Q , Q + q , x) - Q ;
			ans[i][idx]++ ;
			ans[i+j][idx]++ ;
		}
	}
	for(int i = 0 ; i < n ; ++i)
	{
		for(int j = 1 ; j < q ; ++j)
			ans[i][j] += ans[i][j-1] ;
	}
	for(int i = 0 ; i < q ; ++i)
	{
		for(int j = 0 ; j <= n-l ; ++j)
		{
			int idx = lower_bound(Q , Q + q , Q2[i]) - Q ;
			cout<<ans[j][idx]<<" " ;
		}
		cout<<"\n" ;
	}
	return 0 ;
}		
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 20 ms 1236 KB Output is correct
14 Correct 15 ms 1204 KB Output is correct
15 Correct 14 ms 1208 KB Output is correct
16 Correct 25 ms 1268 KB Output is correct
17 Correct 18 ms 1228 KB Output is correct
18 Correct 18 ms 1224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 489 ms 4724 KB Output is correct
2 Correct 451 ms 4820 KB Output is correct
3 Correct 391 ms 4740 KB Output is correct
4 Correct 397 ms 4716 KB Output is correct
5 Correct 193 ms 2664 KB Output is correct
6 Correct 367 ms 4508 KB Output is correct
7 Correct 150 ms 2656 KB Output is correct
8 Correct 197 ms 3512 KB Output is correct
9 Correct 375 ms 4652 KB Output is correct
10 Correct 379 ms 4692 KB Output is correct
11 Correct 22 ms 1236 KB Output is correct
12 Correct 236 ms 3480 KB Output is correct
13 Correct 243 ms 3048 KB Output is correct
14 Correct 237 ms 3040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 489 ms 4724 KB Output is correct
2 Correct 451 ms 4820 KB Output is correct
3 Correct 391 ms 4740 KB Output is correct
4 Correct 397 ms 4716 KB Output is correct
5 Correct 193 ms 2664 KB Output is correct
6 Correct 367 ms 4508 KB Output is correct
7 Correct 150 ms 2656 KB Output is correct
8 Correct 197 ms 3512 KB Output is correct
9 Correct 375 ms 4652 KB Output is correct
10 Correct 379 ms 4692 KB Output is correct
11 Correct 22 ms 1236 KB Output is correct
12 Correct 236 ms 3480 KB Output is correct
13 Correct 243 ms 3048 KB Output is correct
14 Correct 237 ms 3040 KB Output is correct
15 Correct 388 ms 4580 KB Output is correct
16 Correct 364 ms 4376 KB Output is correct
17 Correct 405 ms 4792 KB Output is correct
18 Correct 398 ms 4752 KB Output is correct
19 Correct 384 ms 4764 KB Output is correct
20 Correct 384 ms 4768 KB Output is correct
21 Correct 396 ms 4760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 20 ms 1236 KB Output is correct
14 Correct 15 ms 1204 KB Output is correct
15 Correct 14 ms 1208 KB Output is correct
16 Correct 25 ms 1268 KB Output is correct
17 Correct 18 ms 1228 KB Output is correct
18 Correct 18 ms 1224 KB Output is correct
19 Correct 489 ms 4724 KB Output is correct
20 Correct 451 ms 4820 KB Output is correct
21 Correct 391 ms 4740 KB Output is correct
22 Correct 397 ms 4716 KB Output is correct
23 Correct 193 ms 2664 KB Output is correct
24 Correct 367 ms 4508 KB Output is correct
25 Correct 150 ms 2656 KB Output is correct
26 Correct 197 ms 3512 KB Output is correct
27 Correct 375 ms 4652 KB Output is correct
28 Correct 379 ms 4692 KB Output is correct
29 Correct 22 ms 1236 KB Output is correct
30 Correct 236 ms 3480 KB Output is correct
31 Correct 243 ms 3048 KB Output is correct
32 Correct 237 ms 3040 KB Output is correct
33 Correct 388 ms 4580 KB Output is correct
34 Correct 364 ms 4376 KB Output is correct
35 Correct 405 ms 4792 KB Output is correct
36 Correct 398 ms 4752 KB Output is correct
37 Correct 384 ms 4764 KB Output is correct
38 Correct 384 ms 4768 KB Output is correct
39 Correct 396 ms 4760 KB Output is correct
40 Correct 629 ms 5444 KB Output is correct
41 Correct 192 ms 4772 KB Output is correct
42 Correct 518 ms 5456 KB Output is correct
43 Correct 498 ms 5128 KB Output is correct
44 Correct 475 ms 5256 KB Output is correct
45 Correct 1055 ms 8520 KB Output is correct
46 Correct 201 ms 5104 KB Output is correct
47 Correct 641 ms 8692 KB Output is correct
48 Correct 584 ms 6924 KB Output is correct
49 Correct 592 ms 7564 KB Output is correct