답안 #754295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754295 2023-06-07T12:22:16 Z MetalPower Lottery (CEOI18_lot) C++14
100 / 100
1039 ms 8568 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 1e4 + 10;

int N, L, Q, arr[MX], que[105], pref[MX], ans[MX][105];
vector<int> sq;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.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 >> que[i];
		sq.push_back(que[i]);
	}

	sort(sq.begin(), sq.end());
	sq.push_back(L);

	pref[0] = 0;
	for(int df = 1; df < N - L + 1; df++){
		for(int i = 0; i + df < N; i++){
			if(arr[i] != arr[i + df]) pref[i] = 1;
			else pref[i] = 0; 
		}
		for(int i = 0; i + df < N; i++){
			pref[i] += (i == 0 ? 0 : pref[i - 1]);
		}
		for(int i = 0; i + df < N - L + 1; i++){
			int curr = pref[i + L - 1] - (i == 0 ? 0 : pref[i - 1]);
			int id = lower_bound(sq.begin(), sq.end(), curr) - sq.begin();
			ans[i][id]++;
			ans[i + df][id]++;
		}
	}

	int sz = sq.size();
	for(int i = 0; i < N; i++){
		for(int j = 1; j < sz; j++) ans[i][j] += ans[i][j - 1];
	}

	for(int i = 0; i < Q; i++){
		int id = lower_bound(sq.begin(), sq.end(), que[i]) - sq.begin();
		for(int k = 0; k < N - L + 1; k++) cout << ans[k][id] << " ";
		cout << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 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 23 ms 1184 KB Output is correct
14 Correct 15 ms 1184 KB Output is correct
15 Correct 13 ms 1180 KB Output is correct
16 Correct 20 ms 1236 KB Output is correct
17 Correct 20 ms 1236 KB Output is correct
18 Correct 18 ms 1192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 515 ms 4492 KB Output is correct
2 Correct 422 ms 4488 KB Output is correct
3 Correct 425 ms 4500 KB Output is correct
4 Correct 395 ms 4424 KB Output is correct
5 Correct 182 ms 4496 KB Output is correct
6 Correct 365 ms 4476 KB Output is correct
7 Correct 182 ms 4488 KB Output is correct
8 Correct 297 ms 4412 KB Output is correct
9 Correct 383 ms 4488 KB Output is correct
10 Correct 437 ms 4412 KB Output is correct
11 Correct 23 ms 1556 KB Output is correct
12 Correct 244 ms 4016 KB Output is correct
13 Correct 218 ms 4476 KB Output is correct
14 Correct 222 ms 4472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 515 ms 4492 KB Output is correct
2 Correct 422 ms 4488 KB Output is correct
3 Correct 425 ms 4500 KB Output is correct
4 Correct 395 ms 4424 KB Output is correct
5 Correct 182 ms 4496 KB Output is correct
6 Correct 365 ms 4476 KB Output is correct
7 Correct 182 ms 4488 KB Output is correct
8 Correct 297 ms 4412 KB Output is correct
9 Correct 383 ms 4488 KB Output is correct
10 Correct 437 ms 4412 KB Output is correct
11 Correct 23 ms 1556 KB Output is correct
12 Correct 244 ms 4016 KB Output is correct
13 Correct 218 ms 4476 KB Output is correct
14 Correct 222 ms 4472 KB Output is correct
15 Correct 404 ms 4484 KB Output is correct
16 Correct 361 ms 4472 KB Output is correct
17 Correct 425 ms 4556 KB Output is correct
18 Correct 419 ms 4460 KB Output is correct
19 Correct 445 ms 4556 KB Output is correct
20 Correct 412 ms 4436 KB Output is correct
21 Correct 409 ms 4452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 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 23 ms 1184 KB Output is correct
14 Correct 15 ms 1184 KB Output is correct
15 Correct 13 ms 1180 KB Output is correct
16 Correct 20 ms 1236 KB Output is correct
17 Correct 20 ms 1236 KB Output is correct
18 Correct 18 ms 1192 KB Output is correct
19 Correct 515 ms 4492 KB Output is correct
20 Correct 422 ms 4488 KB Output is correct
21 Correct 425 ms 4500 KB Output is correct
22 Correct 395 ms 4424 KB Output is correct
23 Correct 182 ms 4496 KB Output is correct
24 Correct 365 ms 4476 KB Output is correct
25 Correct 182 ms 4488 KB Output is correct
26 Correct 297 ms 4412 KB Output is correct
27 Correct 383 ms 4488 KB Output is correct
28 Correct 437 ms 4412 KB Output is correct
29 Correct 23 ms 1556 KB Output is correct
30 Correct 244 ms 4016 KB Output is correct
31 Correct 218 ms 4476 KB Output is correct
32 Correct 222 ms 4472 KB Output is correct
33 Correct 404 ms 4484 KB Output is correct
34 Correct 361 ms 4472 KB Output is correct
35 Correct 425 ms 4556 KB Output is correct
36 Correct 419 ms 4460 KB Output is correct
37 Correct 445 ms 4556 KB Output is correct
38 Correct 412 ms 4436 KB Output is correct
39 Correct 409 ms 4452 KB Output is correct
40 Correct 686 ms 5236 KB Output is correct
41 Correct 40 ms 4608 KB Output is correct
42 Correct 487 ms 5244 KB Output is correct
43 Correct 453 ms 4928 KB Output is correct
44 Correct 500 ms 5052 KB Output is correct
45 Correct 1039 ms 8348 KB Output is correct
46 Correct 46 ms 4876 KB Output is correct
47 Correct 674 ms 8568 KB Output is correct
48 Correct 655 ms 6584 KB Output is correct
49 Correct 644 ms 7352 KB Output is correct