Submission #71006

# Submission time Handle Problem Language Result Execution time Memory
71006 2018-08-24T02:08:47 Z 노영훈(#2202) Lottery (CEOI18_lot) C++11
45 / 100
3000 ms 1440 KB
#include <bits/stdc++.h>
using namespace std;

int n, l, q, m, A[10010], cnt[101][10010], lim, now[10010], K[101], sum[10010];
vector<int> X, P[10010];
vector<pair<int, int>> Q;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>l; m=n-l+1;
	for(int i=1; i<=n; i++) cin>>A[i], X.push_back(A[i]);
	cin>>q; for(int i=1; i<=q; i++) cin>>K[i], Q.push_back({K[i], i});

	sort(Q.begin(), Q.end());

	sort(X.begin(), X.end());
	lim=unique(X.begin(), X.end())-X.begin();
	X.resize(lim);

	for(int i=1; i<=n; i++) A[i]=lower_bound(X.begin(), X.end(), A[i])-X.begin();
	for(int i=1; i<=n; i++) P[A[i]].push_back(i);

	for(int i=1; i<=m; i++){
		for(int j=1; j<=n; j++) now[j]=l;

		for(int j=0; j<lim; j++){
			vector<int> Q;
			for(int p:P[j]) if(i<=p && p<i+l) Q.push_back(p-i);
			if(Q.empty()) continue;

			for(int p:P[j]) for(int q:Q) if(1<=p-q && p-q<=m) now[p-q]--;
		}

/*		cout<<"SOLVING: "<<i<<": \n";
		for(int s=1; s<=m; s++) cout<<now[s]<<' ';
		cout<<'\n';
*/
		for(int j=0; j<=l; j++) sum[j]=0;
		for(int j=1; j<=m; j++) if(j!=i) sum[now[j]]++;

		for(int j=1; j<=l; j++) sum[j]+=sum[j-1];

		for(int j=0, s=0; j<(int)Q.size(); j++){
			int val, idx; tie(val,idx)=Q[j];
			while(s<val) s++;
			cnt[idx][i]=sum[s];
		}
	}
	for(int i=1; i<=q; i++, cout<<'\n') for(int j=1; j<=m; j++) cout<<cnt[i][j]<<' ';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 744 KB Output is correct
3 Correct 3 ms 812 KB Output is correct
4 Correct 3 ms 812 KB Output is correct
5 Correct 3 ms 812 KB Output is correct
6 Correct 2 ms 812 KB Output is correct
7 Correct 3 ms 824 KB Output is correct
8 Correct 4 ms 984 KB Output is correct
9 Correct 7 ms 984 KB Output is correct
10 Correct 5 ms 1020 KB Output is correct
11 Correct 5 ms 1020 KB Output is correct
12 Correct 4 ms 1036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 744 KB Output is correct
3 Correct 3 ms 812 KB Output is correct
4 Correct 3 ms 812 KB Output is correct
5 Correct 3 ms 812 KB Output is correct
6 Correct 2 ms 812 KB Output is correct
7 Correct 3 ms 824 KB Output is correct
8 Correct 4 ms 984 KB Output is correct
9 Correct 7 ms 984 KB Output is correct
10 Correct 5 ms 1020 KB Output is correct
11 Correct 5 ms 1020 KB Output is correct
12 Correct 4 ms 1036 KB Output is correct
13 Correct 23 ms 1036 KB Output is correct
14 Correct 90 ms 1260 KB Output is correct
15 Correct 85 ms 1260 KB Output is correct
16 Correct 72 ms 1260 KB Output is correct
17 Correct 60 ms 1260 KB Output is correct
18 Correct 64 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 499 ms 1436 KB Output is correct
2 Correct 716 ms 1440 KB Output is correct
3 Correct 400 ms 1440 KB Output is correct
4 Correct 755 ms 1440 KB Output is correct
5 Execution timed out 3043 ms 1440 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 499 ms 1436 KB Output is correct
2 Correct 716 ms 1440 KB Output is correct
3 Correct 400 ms 1440 KB Output is correct
4 Correct 755 ms 1440 KB Output is correct
5 Execution timed out 3043 ms 1440 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 744 KB Output is correct
3 Correct 3 ms 812 KB Output is correct
4 Correct 3 ms 812 KB Output is correct
5 Correct 3 ms 812 KB Output is correct
6 Correct 2 ms 812 KB Output is correct
7 Correct 3 ms 824 KB Output is correct
8 Correct 4 ms 984 KB Output is correct
9 Correct 7 ms 984 KB Output is correct
10 Correct 5 ms 1020 KB Output is correct
11 Correct 5 ms 1020 KB Output is correct
12 Correct 4 ms 1036 KB Output is correct
13 Correct 23 ms 1036 KB Output is correct
14 Correct 90 ms 1260 KB Output is correct
15 Correct 85 ms 1260 KB Output is correct
16 Correct 72 ms 1260 KB Output is correct
17 Correct 60 ms 1260 KB Output is correct
18 Correct 64 ms 1260 KB Output is correct
19 Correct 499 ms 1436 KB Output is correct
20 Correct 716 ms 1440 KB Output is correct
21 Correct 400 ms 1440 KB Output is correct
22 Correct 755 ms 1440 KB Output is correct
23 Execution timed out 3043 ms 1440 KB Time limit exceeded
24 Halted 0 ms 0 KB -