91202024-02-14 20:42:30111A Barbárcpp17Wrong answer 0/1001.1s127764 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 = 20;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		v[i] = i == 0 ? 1 : random(v[i - 1] + 1, v[i - 1] + 20);
		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();
	}
	vector<int> pf(N, 0);
	vector<int> sf(N, N - 1);
	for (int i = 1; i <= N - 1; i++) {
		pf[i] = max(pf[i - 1], a[i]);
	}
	for (int i = N - 2; i >= 0; i--) {
		sf[i] = min(sf[i + 1], b[i]);
	}
//	for(int i=0;i<N;i++)cout<<setw(3)<<i<<' ';cout<<endl;
//	for(int i=0;i<N;i++)cout<<setw(3)<<v[i]<<' ';cout<<endl;
//	for(int i=0;i<N;i++)cout<<setw(3)<<a[i]<<' ';cout<<endl;
//	for(int i=0;i<N;i++)cout<<setw(3)<<b[i]<<' ';cout<<endl;
//	return 0;
	for (int i = 1; i < N - 1; i++) {
		ans[i] = *min_element(b.begin() + pf[i], b.end()) >= i ? 0 : N - 1;
	}
	for (int i = 0; i < N; i++) {
		cout << setw(3) << ans[i] << ' ';
	}
	cout << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2060 KiB
subtask20/12
3Accepted3ms2144 KiB
4Wrong answer3ms2372 KiB
5Wrong answer3ms2488 KiB
6Wrong answer3ms2700 KiB
7Wrong answer2ms2556 KiB
8Wrong answer3ms2692 KiB
9Wrong answer3ms2776 KiB
10Wrong answer3ms2988 KiB
11Wrong answer3ms3072 KiB
12Wrong answer3ms3072 KiB
subtask30/28
13Wrong answer3ms3372 KiB
14Wrong answer4ms3596 KiB
15Wrong answer3ms3472 KiB
16Wrong answer3ms3528 KiB
17Wrong answer4ms3796 KiB
18Accepted3ms3804 KiB
19Accepted4ms4072 KiB
20Wrong answer3ms4028 KiB
21Wrong answer3ms4040 KiB
subtask40/35
22Time limit exceeded1.1s8936 KiB
23Time limit exceeded1.062s10172 KiB
24Time limit exceeded1.054s10904 KiB
25Time limit exceeded1.062s12024 KiB
26Time limit exceeded1.054s10732 KiB
27Time limit exceeded1.065s13312 KiB
28Time limit exceeded1.041s13828 KiB
29Time limit exceeded1.057s14516 KiB
30Time limit exceeded1.065s15092 KiB
31Time limit exceeded1.08s16336 KiB
subtask50/25
32Time limit exceeded1.055s66464 KiB
33Time limit exceeded1.042s61696 KiB
34Time limit exceeded1.082s66368 KiB
35Time limit exceeded1.075s61724 KiB
36Time limit exceeded1.067s64440 KiB
37Time limit exceeded1.044s66340 KiB
38Time limit exceeded1.059s65384 KiB
39Time limit exceeded1.059s66428 KiB
40Time limit exceeded1.08s66496 KiB
41Time limit exceeded1.064s66228 KiB
42Time limit exceeded1.07s66560 KiB
43Time limit exceeded1.069s76868 KiB
44Time limit exceeded1.062s88532 KiB
45Time limit exceeded1.059s98160 KiB
46Time limit exceeded1.059s107900 KiB
47Time limit exceeded1.049s120696 KiB
48Time limit exceeded1.088s127748 KiB
49Time limit exceeded1.067s127764 KiB
50Time limit exceeded1.065s127536 KiB