답안 #259888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259888 2020-08-08T18:57:41 Z pedroslrey Lottery (CEOI18_lot) C++17
80 / 100
3000 ms 704 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e4 + 10;

int xs[MAXN];
int ans[MAXN];

int main() {
	int n, l;
	scanf("%d%d", &n, &l);

	for (int i = 0; i < n; ++i)
		scanf("%d", &xs[i]);

	int q;
	scanf("%d", &q);
	while (q--) {
		int k;
		scanf("%d", &k);

		for (int space = 1; space + l - 1 < n; ++space) {
			int diffs = 0;
			for (int i = 0; i < l; ++i)
				if (xs[i] != xs[i + space])
					++diffs;

			if (diffs <= k)
				++ans[0], ++ans[space];

			for (int i = 1; i + space + l - 1 < n; ++i) {
				if (xs[i-1] != xs[i + space - 1])
					--diffs;

				if (xs[i + l - 1] != xs[i + l + space - 1])
					++diffs;

				if (diffs <= k)
					++ans[i], ++ans[i + space];
			}
		}
		for (int i = 0; i < n - l + 1; ++i) {
			printf("%d ", ans[i]);
			ans[i] = 0;
		}
		printf("\n");
	}
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &l);
  ~~~~~^~~~~~~~~~~~~~~~
lot.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &xs[i]);
   ~~~~~^~~~~~~~~~~~~~
lot.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
lot.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 47 ms 388 KB Output is correct
14 Correct 61 ms 384 KB Output is correct
15 Correct 41 ms 384 KB Output is correct
16 Correct 104 ms 632 KB Output is correct
17 Correct 100 ms 384 KB Output is correct
18 Correct 93 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 406 ms 384 KB Output is correct
2 Correct 587 ms 456 KB Output is correct
3 Correct 198 ms 504 KB Output is correct
4 Correct 131 ms 512 KB Output is correct
5 Correct 70 ms 504 KB Output is correct
6 Correct 128 ms 512 KB Output is correct
7 Correct 62 ms 632 KB Output is correct
8 Correct 88 ms 512 KB Output is correct
9 Correct 137 ms 632 KB Output is correct
10 Correct 138 ms 512 KB Output is correct
11 Correct 14 ms 384 KB Output is correct
12 Correct 103 ms 504 KB Output is correct
13 Correct 82 ms 504 KB Output is correct
14 Correct 94 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 406 ms 384 KB Output is correct
2 Correct 587 ms 456 KB Output is correct
3 Correct 198 ms 504 KB Output is correct
4 Correct 131 ms 512 KB Output is correct
5 Correct 70 ms 504 KB Output is correct
6 Correct 128 ms 512 KB Output is correct
7 Correct 62 ms 632 KB Output is correct
8 Correct 88 ms 512 KB Output is correct
9 Correct 137 ms 632 KB Output is correct
10 Correct 138 ms 512 KB Output is correct
11 Correct 14 ms 384 KB Output is correct
12 Correct 103 ms 504 KB Output is correct
13 Correct 82 ms 504 KB Output is correct
14 Correct 94 ms 504 KB Output is correct
15 Correct 214 ms 504 KB Output is correct
16 Correct 123 ms 512 KB Output is correct
17 Correct 163 ms 632 KB Output is correct
18 Correct 140 ms 512 KB Output is correct
19 Correct 138 ms 532 KB Output is correct
20 Correct 140 ms 512 KB Output is correct
21 Correct 144 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 47 ms 388 KB Output is correct
14 Correct 61 ms 384 KB Output is correct
15 Correct 41 ms 384 KB Output is correct
16 Correct 104 ms 632 KB Output is correct
17 Correct 100 ms 384 KB Output is correct
18 Correct 93 ms 384 KB Output is correct
19 Correct 406 ms 384 KB Output is correct
20 Correct 587 ms 456 KB Output is correct
21 Correct 198 ms 504 KB Output is correct
22 Correct 131 ms 512 KB Output is correct
23 Correct 70 ms 504 KB Output is correct
24 Correct 128 ms 512 KB Output is correct
25 Correct 62 ms 632 KB Output is correct
26 Correct 88 ms 512 KB Output is correct
27 Correct 137 ms 632 KB Output is correct
28 Correct 138 ms 512 KB Output is correct
29 Correct 14 ms 384 KB Output is correct
30 Correct 103 ms 504 KB Output is correct
31 Correct 82 ms 504 KB Output is correct
32 Correct 94 ms 504 KB Output is correct
33 Correct 214 ms 504 KB Output is correct
34 Correct 123 ms 512 KB Output is correct
35 Correct 163 ms 632 KB Output is correct
36 Correct 140 ms 512 KB Output is correct
37 Correct 138 ms 532 KB Output is correct
38 Correct 140 ms 512 KB Output is correct
39 Correct 144 ms 512 KB Output is correct
40 Execution timed out 3047 ms 704 KB Time limit exceeded
41 Halted 0 ms 0 KB -