91212024-02-14 21:09:41111A Barbárcpp17Time limit exceeded 40/1001.1s35588 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define pii pair<int, int>

int random(int l, int h) {
	static mt19937 gen;
	return uniform_int_distribution<int>(l, h)(gen);
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef CB
	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	int N = 50;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		v[i] = random(1, 1000000);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	vector<int> ans(N);
	ans[0] = N - 1;
	ans[N - 1] = 0;
//	for (int i = 1; i < N - 1; i++) {
//		list<int> l(v.begin(), v.end());
//		auto t = next(l.begin(), i);
//		while (true) {
//			if (*t - *prev(t) <= *next(t) - *t) {
//				t = prev(l.erase(t));
//			}
//			else {
//				t = l.erase(t);
//			}
//			if (t == l.begin()) {
//				ans[i] = N - 1;
//				break;
//			}
//			if (t == prev(l.end())) {
//				ans[i] = 0;
//				break;
//			}
//		}
//	}
//	for (int i = 0; i < N; i++) {
//		cout << setw(3) << ans[i] << ' ';
//	}
//	cout << '\n';
	vector<int> a(N, 0);
	vector<int> b(N, N - 1);
	for (int i = 1; i <= N - 2; i++) {
		a[i] = lower_bound(v.begin(), v.end(), v[i] * 2 - v[i - 1]) - v.begin() - 1;
		b[i] = lower_bound(v.begin(), v.end(), v[i] * 2 - v[i + 1]) - v.begin();
	}
	for (int i = 1; i < N - 1; i++) {
		int h = i;
		for (int j = i; j > 0; j--) {
			if (a[j] > h) {
				while (h < N && b[h] >= j) {
					h++;
				}
			}
		}
		ans[i] = h == N ? 0 : N - 1;
	}
	for (int i = 0; i < N; i++) {
		cout << setw(3) << ans[i] << ' ';
	}
	cout << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2064 KiB
subtask212/12
3Accepted3ms2284 KiB
4Accepted3ms2452 KiB
5Accepted3ms2676 KiB
6Accepted3ms2768 KiB
7Accepted3ms2976 KiB
8Accepted3ms3184 KiB
9Accepted3ms3404 KiB
10Accepted3ms3484 KiB
11Accepted3ms3604 KiB
12Accepted3ms3696 KiB
subtask328/28
13Accepted3ms3724 KiB
14Accepted3ms3984 KiB
15Accepted3ms3940 KiB
16Accepted3ms3940 KiB
17Accepted3ms3944 KiB
18Accepted3ms4348 KiB
19Accepted3ms4364 KiB
20Accepted3ms4432 KiB
21Accepted3ms4328 KiB
subtask40/35
22Time limit exceeded1.1s6864 KiB
23Time limit exceeded1.054s6760 KiB
24Time limit exceeded1.062s6884 KiB
25Time limit exceeded1.057s6964 KiB
26Time limit exceeded1.077s5644 KiB
27Time limit exceeded1.054s6820 KiB
28Time limit exceeded1.049s6908 KiB
29Time limit exceeded1.085s6876 KiB
30Time limit exceeded1.057s6828 KiB
31Time limit exceeded1.065s6824 KiB
subtask50/25
32Time limit exceeded1.072s35032 KiB
33Time limit exceeded1.042s31912 KiB
34Time limit exceeded1.074s35048 KiB
35Time limit exceeded1.057s31988 KiB
36Time limit exceeded1.057s33828 KiB
37Time limit exceeded1.074s35212 KiB
38Time limit exceeded1.067s34468 KiB
39Time limit exceeded1.065s35104 KiB
40Time limit exceeded1.065s35028 KiB
41Time limit exceeded1.078s35048 KiB
42Time limit exceeded1.054s34008 KiB
43Time limit exceeded1.065s34600 KiB
44Time limit exceeded1.05s35180 KiB
45Time limit exceeded1.065s35100 KiB
46Time limit exceeded1.07s35280 KiB
47Time limit exceeded1.052s35376 KiB
48Time limit exceeded1.075s35476 KiB
49Time limit exceeded1.085s35588 KiB
50Time limit exceeded1.065s35532 KiB