Submission #70992

# Submission time Handle Problem Language Result Execution time Memory
70992 2018-08-24T01:29:39 Z 윤교준(#2204) Lottery (CEOI18_lot) C++11
100 / 100
1002 ms 8748 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const int MAXN = 10005;
const int MAXQ = 105;

int D[MAXN];
int A[MAXN];
int B[MAXQ];

int Ans[MAXN][MAXQ];
int N, L, Q;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> L;
	for(int i = 1; i <= N; i++) cin >> A[i];
	cin >> Q;
	for(int i = 1; i <= Q; i++) cin >> B[i];

	{
		vector<int> V;
		for(int i = 1; i <= Q; i++) V.eb(B[i]);
		sorv(V); univ(V);

		for(int i = 0; i <= V[0]; i++) D[i] = 1;
		for(int i = 1; i < sz(V); i++) {
			for(int j = V[i-1]+1; j <= V[i]; j++)
				D[j] = i+1;
		}
	}

	{
		vector<int> C(N+5, 0);

		for(int l = 1; l <= N-L; l++) {
			for(int i = 1; i <= N; i++) C[i] = 0;
			for(int s = 1, e = 1+l; e <= N; s++, e++) {
				C[s] = (A[s] == A[e] ? 0 : 1);
			}
			for(int i = 1; i <= N; i++) C[i] += C[i-1];
			for(int s = 1, e = 1+l; e+L-1 <= N; s++, e++) {
				int t = C[s+L-1] - C[s-1];
				Ans[s][D[t]]++;
				Ans[e][D[t]]++;
			}
		}
	}

	for(int i = 1; i <= N; i++) {
		for(int j = 2; j <= Q; j++)
			Ans[i][j] += Ans[i][j-1];
	}

	for(int i = 1; i <= Q; i++) {
		for(int j = 1; j <= N-L+1; j++)
			printf("%d ", Ans[j][D[B[i]]]);
		puts("");
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
7 Correct 3 ms 564 KB Output is correct
8 Correct 3 ms 696 KB Output is correct
9 Correct 3 ms 708 KB Output is correct
10 Correct 6 ms 836 KB Output is correct
11 Correct 5 ms 836 KB Output is correct
12 Correct 3 ms 836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
7 Correct 3 ms 564 KB Output is correct
8 Correct 3 ms 696 KB Output is correct
9 Correct 3 ms 708 KB Output is correct
10 Correct 6 ms 836 KB Output is correct
11 Correct 5 ms 836 KB Output is correct
12 Correct 3 ms 836 KB Output is correct
13 Correct 39 ms 1424 KB Output is correct
14 Correct 26 ms 1552 KB Output is correct
15 Correct 20 ms 1552 KB Output is correct
16 Correct 31 ms 1552 KB Output is correct
17 Correct 30 ms 1552 KB Output is correct
18 Correct 29 ms 1584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 793 ms 4888 KB Output is correct
2 Correct 870 ms 4888 KB Output is correct
3 Correct 887 ms 4908 KB Output is correct
4 Correct 849 ms 4908 KB Output is correct
5 Correct 325 ms 4908 KB Output is correct
6 Correct 710 ms 4908 KB Output is correct
7 Correct 319 ms 4908 KB Output is correct
8 Correct 503 ms 4908 KB Output is correct
9 Correct 793 ms 4908 KB Output is correct
10 Correct 828 ms 4908 KB Output is correct
11 Correct 38 ms 4908 KB Output is correct
12 Correct 449 ms 4908 KB Output is correct
13 Correct 407 ms 4908 KB Output is correct
14 Correct 398 ms 4908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 793 ms 4888 KB Output is correct
2 Correct 870 ms 4888 KB Output is correct
3 Correct 887 ms 4908 KB Output is correct
4 Correct 849 ms 4908 KB Output is correct
5 Correct 325 ms 4908 KB Output is correct
6 Correct 710 ms 4908 KB Output is correct
7 Correct 319 ms 4908 KB Output is correct
8 Correct 503 ms 4908 KB Output is correct
9 Correct 793 ms 4908 KB Output is correct
10 Correct 828 ms 4908 KB Output is correct
11 Correct 38 ms 4908 KB Output is correct
12 Correct 449 ms 4908 KB Output is correct
13 Correct 407 ms 4908 KB Output is correct
14 Correct 398 ms 4908 KB Output is correct
15 Correct 807 ms 4908 KB Output is correct
16 Correct 677 ms 4908 KB Output is correct
17 Correct 876 ms 4908 KB Output is correct
18 Correct 796 ms 4908 KB Output is correct
19 Correct 776 ms 4908 KB Output is correct
20 Correct 765 ms 4908 KB Output is correct
21 Correct 764 ms 4908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
7 Correct 3 ms 564 KB Output is correct
8 Correct 3 ms 696 KB Output is correct
9 Correct 3 ms 708 KB Output is correct
10 Correct 6 ms 836 KB Output is correct
11 Correct 5 ms 836 KB Output is correct
12 Correct 3 ms 836 KB Output is correct
13 Correct 39 ms 1424 KB Output is correct
14 Correct 26 ms 1552 KB Output is correct
15 Correct 20 ms 1552 KB Output is correct
16 Correct 31 ms 1552 KB Output is correct
17 Correct 30 ms 1552 KB Output is correct
18 Correct 29 ms 1584 KB Output is correct
19 Correct 793 ms 4888 KB Output is correct
20 Correct 870 ms 4888 KB Output is correct
21 Correct 887 ms 4908 KB Output is correct
22 Correct 849 ms 4908 KB Output is correct
23 Correct 325 ms 4908 KB Output is correct
24 Correct 710 ms 4908 KB Output is correct
25 Correct 319 ms 4908 KB Output is correct
26 Correct 503 ms 4908 KB Output is correct
27 Correct 793 ms 4908 KB Output is correct
28 Correct 828 ms 4908 KB Output is correct
29 Correct 38 ms 4908 KB Output is correct
30 Correct 449 ms 4908 KB Output is correct
31 Correct 407 ms 4908 KB Output is correct
32 Correct 398 ms 4908 KB Output is correct
33 Correct 807 ms 4908 KB Output is correct
34 Correct 677 ms 4908 KB Output is correct
35 Correct 876 ms 4908 KB Output is correct
36 Correct 796 ms 4908 KB Output is correct
37 Correct 776 ms 4908 KB Output is correct
38 Correct 765 ms 4908 KB Output is correct
39 Correct 764 ms 4908 KB Output is correct
40 Correct 831 ms 5676 KB Output is correct
41 Correct 71 ms 5676 KB Output is correct
42 Correct 912 ms 5676 KB Output is correct
43 Correct 834 ms 5676 KB Output is correct
44 Correct 1002 ms 5676 KB Output is correct
45 Correct 968 ms 8556 KB Output is correct
46 Correct 67 ms 8556 KB Output is correct
47 Correct 999 ms 8748 KB Output is correct
48 Correct 956 ms 8748 KB Output is correct
49 Correct 986 ms 8748 KB Output is correct