Submission #754281

# Submission time Handle Problem Language Result Execution time Memory
754281 2023-06-07T12:04:58 Z MetalPower Lottery (CEOI18_lot) C++14
35 / 100
619 ms 4556 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 1e4 + 10;

int N, L, Q, arr[MX], que[MX], 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 < N - df; i++){
			if(arr[i] != arr[i + df]) pref[i] = (i == 0 ? 1 : pref[i - 1] + 1);
			else pref[i] = (i == 0 ? 0 : pref[i - 1]); 
		}
		for(int i = 0; i < N - L + 1 - df; 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 - L + 1; 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][i] << " ";
		cout << '\n';
	}
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:44:7: warning: unused variable 'id' [-Wunused-variable]
   44 |   int id = lower_bound(sq.begin(), sq.end(), que[i]) - sq.begin();
      |       ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 619 ms 4496 KB Output is correct
2 Correct 581 ms 4500 KB Output is correct
3 Correct 374 ms 4496 KB Output is correct
4 Correct 385 ms 4416 KB Output is correct
5 Correct 160 ms 2456 KB Output is correct
6 Correct 334 ms 4208 KB Output is correct
7 Correct 143 ms 2444 KB Output is correct
8 Correct 231 ms 3284 KB Output is correct
9 Correct 368 ms 4356 KB Output is correct
10 Correct 409 ms 4416 KB Output is correct
11 Correct 19 ms 1108 KB Output is correct
12 Correct 225 ms 3248 KB Output is correct
13 Correct 222 ms 2816 KB Output is correct
14 Correct 186 ms 2812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 619 ms 4496 KB Output is correct
2 Correct 581 ms 4500 KB Output is correct
3 Correct 374 ms 4496 KB Output is correct
4 Correct 385 ms 4416 KB Output is correct
5 Correct 160 ms 2456 KB Output is correct
6 Correct 334 ms 4208 KB Output is correct
7 Correct 143 ms 2444 KB Output is correct
8 Correct 231 ms 3284 KB Output is correct
9 Correct 368 ms 4356 KB Output is correct
10 Correct 409 ms 4416 KB Output is correct
11 Correct 19 ms 1108 KB Output is correct
12 Correct 225 ms 3248 KB Output is correct
13 Correct 222 ms 2816 KB Output is correct
14 Correct 186 ms 2812 KB Output is correct
15 Correct 372 ms 4360 KB Output is correct
16 Correct 328 ms 4092 KB Output is correct
17 Correct 394 ms 4492 KB Output is correct
18 Correct 364 ms 4452 KB Output is correct
19 Correct 374 ms 4556 KB Output is correct
20 Correct 456 ms 4452 KB Output is correct
21 Correct 387 ms 4460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -