Submission #720577

# Submission time Handle Problem Language Result Execution time Memory
720577 2023-04-08T13:46:21 Z 406 Lottery (CEOI18_lot) C++17
100 / 100
488 ms 8272 KB
#include "bits/stdc++.h"
using namespace std;
const long long INF = 1ll << 60;
const int N = 1e4 + 5;
const int Q = 100 + 5;
int dp[N], ans[Q][N], n, q, a[N], K[N], l, ps[N];

void add(const int k) {
	memset(ps, 0, sizeof ps);
	for (int i = 0; i <= n - l; i++) ps[dp[i]]++;
	for (int i = 1; i <= l; i++) ps[i] += ps[i - 1];
	for (int i = 0; i < q; i++) ans[i][k] = ps[K[i]];
}

signed main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> l;

	for (int i = 0; i < n; i++) cin >> a[i];
	cin >> q;
	for (int i = 0; i < q; i++) cin >> K[i];

	for (int i = 0; i <= n - l; i++) for (int j = 0; j < l; j++) dp[i] += a[j] != a[j + i];
	
	add(0);
	for (int i = 1; i <= n - l; i++) {
		for (int j = n - l; j; j--) dp[j] = dp[j - 1] + (a[i + l - 1] != a[j + l - 1]) - (a[i - 1] != a[j - 1]);
		dp[0] = 0;
		for (int j = 0; j < l; j++) dp[0] += a[j] != a[j + i];
		add(i);
	}

	for (int i = 0; i < q; i++) {
		for (int j = 0; j <= n - l; j++) {
			cout << ans[i][j] - 1 << ' ';
		}
		cout << '\n';
	}

	return 0;
}
//به زآن که فروشند چه خواهند خرید
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 452 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 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 456 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 452 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 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 456 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 20 ms 432 KB Output is correct
14 Correct 16 ms 568 KB Output is correct
15 Correct 15 ms 468 KB Output is correct
16 Correct 23 ms 716 KB Output is correct
17 Correct 24 ms 664 KB Output is correct
18 Correct 21 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 420 ms 592 KB Output is correct
2 Correct 405 ms 480 KB Output is correct
3 Correct 427 ms 596 KB Output is correct
4 Correct 429 ms 560 KB Output is correct
5 Correct 231 ms 528 KB Output is correct
6 Correct 393 ms 540 KB Output is correct
7 Correct 227 ms 532 KB Output is correct
8 Correct 307 ms 564 KB Output is correct
9 Correct 401 ms 560 KB Output is correct
10 Correct 408 ms 548 KB Output is correct
11 Correct 25 ms 340 KB Output is correct
12 Correct 244 ms 656 KB Output is correct
13 Correct 254 ms 604 KB Output is correct
14 Correct 232 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 420 ms 592 KB Output is correct
2 Correct 405 ms 480 KB Output is correct
3 Correct 427 ms 596 KB Output is correct
4 Correct 429 ms 560 KB Output is correct
5 Correct 231 ms 528 KB Output is correct
6 Correct 393 ms 540 KB Output is correct
7 Correct 227 ms 532 KB Output is correct
8 Correct 307 ms 564 KB Output is correct
9 Correct 401 ms 560 KB Output is correct
10 Correct 408 ms 548 KB Output is correct
11 Correct 25 ms 340 KB Output is correct
12 Correct 244 ms 656 KB Output is correct
13 Correct 254 ms 604 KB Output is correct
14 Correct 232 ms 528 KB Output is correct
15 Correct 366 ms 592 KB Output is correct
16 Correct 355 ms 560 KB Output is correct
17 Correct 406 ms 572 KB Output is correct
18 Correct 410 ms 552 KB Output is correct
19 Correct 416 ms 556 KB Output is correct
20 Correct 431 ms 688 KB Output is correct
21 Correct 404 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 452 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 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 456 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 20 ms 432 KB Output is correct
14 Correct 16 ms 568 KB Output is correct
15 Correct 15 ms 468 KB Output is correct
16 Correct 23 ms 716 KB Output is correct
17 Correct 24 ms 664 KB Output is correct
18 Correct 21 ms 628 KB Output is correct
19 Correct 420 ms 592 KB Output is correct
20 Correct 405 ms 480 KB Output is correct
21 Correct 427 ms 596 KB Output is correct
22 Correct 429 ms 560 KB Output is correct
23 Correct 231 ms 528 KB Output is correct
24 Correct 393 ms 540 KB Output is correct
25 Correct 227 ms 532 KB Output is correct
26 Correct 307 ms 564 KB Output is correct
27 Correct 401 ms 560 KB Output is correct
28 Correct 408 ms 548 KB Output is correct
29 Correct 25 ms 340 KB Output is correct
30 Correct 244 ms 656 KB Output is correct
31 Correct 254 ms 604 KB Output is correct
32 Correct 232 ms 528 KB Output is correct
33 Correct 366 ms 592 KB Output is correct
34 Correct 355 ms 560 KB Output is correct
35 Correct 406 ms 572 KB Output is correct
36 Correct 410 ms 552 KB Output is correct
37 Correct 416 ms 556 KB Output is correct
38 Correct 431 ms 688 KB Output is correct
39 Correct 404 ms 552 KB Output is correct
40 Correct 356 ms 2004 KB Output is correct
41 Correct 46 ms 624 KB Output is correct
42 Correct 389 ms 1996 KB Output is correct
43 Correct 423 ms 1696 KB Output is correct
44 Correct 418 ms 1740 KB Output is correct
45 Correct 435 ms 8096 KB Output is correct
46 Correct 53 ms 1484 KB Output is correct
47 Correct 466 ms 8272 KB Output is correct
48 Correct 448 ms 6548 KB Output is correct
49 Correct 488 ms 7220 KB Output is correct