#include <bits/stdc++.h>
using namespace std;
#define int long long
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 = 1000;
cin >> N;
vector<int> v(N);
for (int i = 0; i < N; i++) {
v[i] = random(1, 1000000000);
}
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);
vector<int> b(N);
vector<int> c(N);
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();
c[i] = i;
}
vector<vector<int>> rb(N);
for (int i = 0; i <= N - 1; i++) {
rb[b[i]].push_back(i);
}
auto update_greater = [&](int l, int r, int x, int y) {
while (r >= l) {
if (c[r] > x) {
c[r] = y;
}
r--;
}
};
auto update_less = [&](int l, int r, int x, int y) {
while (r >= l) {
if (c[r] < x) {
c[r] = y;
}
r--;
}
};
for (int i = N - 1; i >= 0; i--) {
for (int j : rb[i]) {
update_greater(0, j, j, j);
}
update_less(0, a[i] - 1, a[i], N - 1);
}
for (int i = 1; i < N - 1; i++) {
ans[i] = (c[i] == N - 1) ? 0 : N - 1;
}
for (int i = 0; i < N; i++) {
cout << ans[i] << ' ';
}
cout << '\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1836 KiB | ||||
2 | Accepted | 3ms | 2048 KiB | ||||
subtask2 | 12/12 | ||||||
3 | Accepted | 3ms | 2148 KiB | ||||
4 | Accepted | 3ms | 2336 KiB | ||||
5 | Accepted | 3ms | 2548 KiB | ||||
6 | Accepted | 3ms | 2784 KiB | ||||
7 | Accepted | 3ms | 2864 KiB | ||||
8 | Accepted | 3ms | 2848 KiB | ||||
9 | Accepted | 3ms | 3204 KiB | ||||
10 | Accepted | 3ms | 3124 KiB | ||||
11 | Accepted | 3ms | 3336 KiB | ||||
12 | Accepted | 3ms | 3424 KiB | ||||
subtask3 | 28/28 | ||||||
13 | Accepted | 4ms | 3828 KiB | ||||
14 | Accepted | 4ms | 3844 KiB | ||||
15 | Accepted | 4ms | 4184 KiB | ||||
16 | Accepted | 4ms | 4196 KiB | ||||
17 | Accepted | 4ms | 4204 KiB | ||||
18 | Accepted | 4ms | 4204 KiB | ||||
19 | Accepted | 4ms | 4240 KiB | ||||
20 | Accepted | 4ms | 4360 KiB | ||||
21 | Accepted | 4ms | 4364 KiB | ||||
subtask4 | 0/35 | ||||||
22 | Time limit exceeded | 1.1s | 11516 KiB | ||||
23 | Time limit exceeded | 1.078s | 11640 KiB | ||||
24 | Time limit exceeded | 1.062s | 11620 KiB | ||||
25 | Time limit exceeded | 1.08s | 11656 KiB | ||||
26 | Time limit exceeded | 1.065s | 8144 KiB | ||||
27 | Time limit exceeded | 1.07s | 12800 KiB | ||||
28 | Time limit exceeded | 1.077s | 13016 KiB | ||||
29 | Time limit exceeded | 1.059s | 12988 KiB | ||||
30 | Time limit exceeded | 1.07s | 12968 KiB | ||||
31 | Time limit exceeded | 1.082s | 11756 KiB | ||||
subtask5 | 0/25 | ||||||
32 | Time limit exceeded | 1.041s | 86020 KiB | ||||
33 | Time limit exceeded | 1.062s | 77624 KiB | ||||
34 | Time limit exceeded | 1.047s | 86012 KiB | ||||
35 | Time limit exceeded | 1.077s | 77896 KiB | ||||
36 | Time limit exceeded | 1.088s | 82548 KiB | ||||
37 | Time limit exceeded | 1.064s | 97840 KiB | ||||
38 | Time limit exceeded | 1.065s | 95952 KiB | ||||
39 | Time limit exceeded | 1.085s | 97848 KiB | ||||
40 | Time limit exceeded | 1.078s | 97832 KiB | ||||
41 | Time limit exceeded | 1.069s | 85880 KiB | ||||
42 | Time limit exceeded | 1.08s | 93984 KiB | ||||
43 | Time limit exceeded | 1.065s | 96096 KiB | ||||
44 | Time limit exceeded | 1.072s | 82708 KiB | ||||
45 | Time limit exceeded | 1.057s | 95316 KiB | ||||
46 | Time limit exceeded | 1.055s | 95392 KiB | ||||
47 | Time limit exceeded | 1.059s | 97732 KiB | ||||
48 | Time limit exceeded | 1.078s | 97736 KiB | ||||
49 | Time limit exceeded | 1.08s | 97656 KiB | ||||
50 | Time limit exceeded | 1.052s | 97796 KiB |