Submission #940153

# Submission time Handle Problem Language Result Execution time Memory
940153 2024-03-07T06:06:41 Z vjudge1 Lottery (CEOI18_lot) C++17
45 / 100
3000 ms 888 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
	return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
	return a < b ? (a = b) == b : false;
}

signed main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	int n, l; cin >> n >> l;
	int a[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int q; cin >> q;
	vector<pair<int, int>> qri(q);
	for (int i = 0; i < q; ++i) {
		cin >> qri[i].first;
		qri[i].second = i;
	}
	sort(all(qri));
	int res[q][n];
	for (int i = 0; i + l - 1 < n; ++i) {
		deque<int> x, y;
		for (int j = i; j < i + l; ++j) {
			x.push_back(a[j]);
		}
		for (int j = 0; j < l; ++j) {
			y.push_back(a[j]);
		}
		int cnt = 0;
		for (int k = 0; k < l; ++k) {
			if (x[k] != y[k]) cnt++;
		}
		vector<int> v;
		if (i) v.push_back(cnt);
		for (int j = l; j < n; ++j) {
			y.pop_front();
			y.push_back(a[j]);
			if (j - l + 1 == i) continue;
			cnt = 0;
			for (int k = 0; k < l; ++k) {
				if (x[k] != y[k]) cnt++;
			}
			v.push_back(cnt);
		}
		sort(all(v));
		int s = 0, t = 0, add = 0;
		while (t < q) {
			while (s < size(v) && v[s] <= qri[t].first) {
				add++;
				s++;
			}
			res[qri[t].second][i] = add;
			t++;
		}
	}
	for (int i = 0; i < q; ++i) {
		for (int j = 0; j + l - 1 < n; ++j) {
			cout << res[i][j] << ' ';
		}
		cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 9 ms 476 KB Output is correct
9 Correct 8 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 9 ms 476 KB Output is correct
9 Correct 8 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 110 ms 496 KB Output is correct
14 Correct 2810 ms 848 KB Output is correct
15 Correct 2902 ms 572 KB Output is correct
16 Correct 1615 ms 632 KB Output is correct
17 Correct 2160 ms 628 KB Output is correct
18 Correct 2188 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2958 ms 632 KB Output is correct
2 Execution timed out 3028 ms 604 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2958 ms 632 KB Output is correct
2 Execution timed out 3028 ms 604 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 9 ms 476 KB Output is correct
9 Correct 8 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 110 ms 496 KB Output is correct
14 Correct 2810 ms 848 KB Output is correct
15 Correct 2902 ms 572 KB Output is correct
16 Correct 1615 ms 632 KB Output is correct
17 Correct 2160 ms 628 KB Output is correct
18 Correct 2188 ms 888 KB Output is correct
19 Correct 2958 ms 632 KB Output is correct
20 Execution timed out 3028 ms 604 KB Time limit exceeded
21 Halted 0 ms 0 KB -