답안 #309084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309084 2020-10-02T18:04:56 Z shivensinha4 Lottery (CEOI18_lot) C++17
45 / 100
3000 ms 888 KB
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

const int MXN = 10000, MXQ = 100;
int ans[MXQ+1][MXN+1], nums[MXN+1], match[MXN+1], freq[MXN+3], qr[MXQ+1];

int main() {
	#ifdef shiven
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, l; cin >> n >> l;
	vector<ii> val(n);
	for_(i, 0, n) {
		cin >> nums[i];
		val[i] = {nums[i], i};
	}
	
	sort(val.begin(), val.end());
	int pt = -1;
	for_(i, 0, n) {
		if (i > 0 and val[i].first == val[i-1].first) nums[val[i].second] = pt;
		else nums[val[i].second] = ++pt;
	}
	
	vector<vi> pos(pt+1);
	for_(i, 0, n) pos[nums[i]].push_back(i);
	
	int q; cin >> q;
	for_(i, 0, q) cin >> qr[i];
	
	for_(i, 0, n-l+1) {
		memset(match, 0, sizeof(match)); memset(freq, 0, sizeof(freq));
		for_(j, 0, l) for (auto p: pos[nums[i+j]]) if (p >= j and p != i+j) match[p-j] += 1;
		int mx = 0;
		for_(j, 0, n-l+1) if (i != j) {
			freq[match[j]] += 1;
			mx = max(mx, match[j]);
		}
		for (int j = mx-1; j >= 0; j--) freq[j] += freq[j+1];
		for_(j, 0, q) ans[j][i] = freq[l-qr[j]];
	}
	
	for_(i, 0, q) {
		for_(j, 0, n-l+1) cout << ans[i][j] << " ";
		cout << endl;
	}
	
	cout << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 25 ms 512 KB Output is correct
14 Correct 20 ms 792 KB Output is correct
15 Correct 62 ms 612 KB Output is correct
16 Correct 104 ms 816 KB Output is correct
17 Correct 25 ms 760 KB Output is correct
18 Correct 31 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 775 ms 684 KB Output is correct
2 Correct 1304 ms 764 KB Output is correct
3 Correct 404 ms 832 KB Output is correct
4 Correct 648 ms 888 KB Output is correct
5 Execution timed out 3088 ms 768 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 775 ms 684 KB Output is correct
2 Correct 1304 ms 764 KB Output is correct
3 Correct 404 ms 832 KB Output is correct
4 Correct 648 ms 888 KB Output is correct
5 Execution timed out 3088 ms 768 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 25 ms 512 KB Output is correct
14 Correct 20 ms 792 KB Output is correct
15 Correct 62 ms 612 KB Output is correct
16 Correct 104 ms 816 KB Output is correct
17 Correct 25 ms 760 KB Output is correct
18 Correct 31 ms 760 KB Output is correct
19 Correct 775 ms 684 KB Output is correct
20 Correct 1304 ms 764 KB Output is correct
21 Correct 404 ms 832 KB Output is correct
22 Correct 648 ms 888 KB Output is correct
23 Execution timed out 3088 ms 768 KB Time limit exceeded
24 Halted 0 ms 0 KB -