Submission #528732

# Submission time Handle Problem Language Result Execution time Memory
528732 2022-02-21T08:38:37 Z sidon Lottery (CEOI18_lot) C++17
100 / 100
715 ms 8292 KB
#include <bits/stdc++.h>
using namespace std;

const int Z = 10001;

int n, l, q, a[Z], d[Z][102];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);

	cin >> n >> l;

	for(int i = 1; i <= n; ++i)
		cin >> a[i];

	cin >> q;

	int qry[q];
	vector<int> vals = {0, n};

	for(int &i : qry) {
		cin >> i;
		vals.push_back(i);
	}

	sort(begin(vals), end(vals));
	vals.erase(unique(begin(vals), end(vals)), end(vals));

	int C[n+1];

	for(int i = 0; i <= n; ++i)
		C[i] = lower_bound(begin(vals), end(vals), i) - begin(vals);

	for(int j = 1; j + l <= n; ++j) {
		int cur = 0;

		for(int i = 1; i < l; ++i)
			cur += a[i] != a[i+j];

		for(int i = 1; i + j + l - 1 <= n; ++i) {
			cur -= i > 1 && a[i-1] != a[i+j-1];
			cur += a[i+l-1] != a[i+j+l-1];

			++d[i][C[cur]];
			++d[i+j][C[cur]];
		}
	}

	for(int i = 1; i <= n; ++i)
		partial_sum(d[i], d[i] + 102, d[i]);

	for(int v : qry) {
		for(int i = 1; i + l - 1 <= n; ++i)
			cout << d[i][C[v]] << ' ';
		cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 19 ms 1100 KB Output is correct
14 Correct 10 ms 1100 KB Output is correct
15 Correct 10 ms 1124 KB Output is correct
16 Correct 19 ms 1228 KB Output is correct
17 Correct 14 ms 1100 KB Output is correct
18 Correct 14 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 648 ms 4360 KB Output is correct
2 Correct 655 ms 4356 KB Output is correct
3 Correct 445 ms 4360 KB Output is correct
4 Correct 405 ms 4280 KB Output is correct
5 Correct 116 ms 4292 KB Output is correct
6 Correct 346 ms 4420 KB Output is correct
7 Correct 125 ms 4288 KB Output is correct
8 Correct 210 ms 4292 KB Output is correct
9 Correct 378 ms 4372 KB Output is correct
10 Correct 396 ms 4300 KB Output is correct
11 Correct 19 ms 1516 KB Output is correct
12 Correct 211 ms 3908 KB Output is correct
13 Correct 165 ms 4280 KB Output is correct
14 Correct 157 ms 4268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 648 ms 4360 KB Output is correct
2 Correct 655 ms 4356 KB Output is correct
3 Correct 445 ms 4360 KB Output is correct
4 Correct 405 ms 4280 KB Output is correct
5 Correct 116 ms 4292 KB Output is correct
6 Correct 346 ms 4420 KB Output is correct
7 Correct 125 ms 4288 KB Output is correct
8 Correct 210 ms 4292 KB Output is correct
9 Correct 378 ms 4372 KB Output is correct
10 Correct 396 ms 4300 KB Output is correct
11 Correct 19 ms 1516 KB Output is correct
12 Correct 211 ms 3908 KB Output is correct
13 Correct 165 ms 4280 KB Output is correct
14 Correct 157 ms 4268 KB Output is correct
15 Correct 435 ms 4360 KB Output is correct
16 Correct 337 ms 4348 KB Output is correct
17 Correct 420 ms 4356 KB Output is correct
18 Correct 394 ms 4420 KB Output is correct
19 Correct 410 ms 4420 KB Output is correct
20 Correct 402 ms 4320 KB Output is correct
21 Correct 393 ms 4336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 19 ms 1100 KB Output is correct
14 Correct 10 ms 1100 KB Output is correct
15 Correct 10 ms 1124 KB Output is correct
16 Correct 19 ms 1228 KB Output is correct
17 Correct 14 ms 1100 KB Output is correct
18 Correct 14 ms 1132 KB Output is correct
19 Correct 648 ms 4360 KB Output is correct
20 Correct 655 ms 4356 KB Output is correct
21 Correct 445 ms 4360 KB Output is correct
22 Correct 405 ms 4280 KB Output is correct
23 Correct 116 ms 4292 KB Output is correct
24 Correct 346 ms 4420 KB Output is correct
25 Correct 125 ms 4288 KB Output is correct
26 Correct 210 ms 4292 KB Output is correct
27 Correct 378 ms 4372 KB Output is correct
28 Correct 396 ms 4300 KB Output is correct
29 Correct 19 ms 1516 KB Output is correct
30 Correct 211 ms 3908 KB Output is correct
31 Correct 165 ms 4280 KB Output is correct
32 Correct 157 ms 4268 KB Output is correct
33 Correct 435 ms 4360 KB Output is correct
34 Correct 337 ms 4348 KB Output is correct
35 Correct 420 ms 4356 KB Output is correct
36 Correct 394 ms 4420 KB Output is correct
37 Correct 410 ms 4420 KB Output is correct
38 Correct 402 ms 4320 KB Output is correct
39 Correct 393 ms 4336 KB Output is correct
40 Correct 656 ms 5104 KB Output is correct
41 Correct 15 ms 4428 KB Output is correct
42 Correct 419 ms 5084 KB Output is correct
43 Correct 393 ms 4696 KB Output is correct
44 Correct 387 ms 4824 KB Output is correct
45 Correct 715 ms 8160 KB Output is correct
46 Correct 20 ms 4636 KB Output is correct
47 Correct 469 ms 8292 KB Output is correct
48 Correct 429 ms 6364 KB Output is correct
49 Correct 442 ms 7132 KB Output is correct