#include <bits/stdc++.h>
using namespace std;
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 << setw(3) << ans[i] << ' ';
}
cout << '\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2024 KiB | ||||
subtask2 | 12/12 | ||||||
3 | Accepted | 3ms | 2240 KiB | ||||
4 | Accepted | 2ms | 2320 KiB | ||||
5 | Accepted | 3ms | 2468 KiB | ||||
6 | Accepted | 3ms | 2544 KiB | ||||
7 | Accepted | 3ms | 2636 KiB | ||||
8 | Accepted | 3ms | 2760 KiB | ||||
9 | Accepted | 3ms | 2724 KiB | ||||
10 | Accepted | 3ms | 2964 KiB | ||||
11 | Accepted | 3ms | 2968 KiB | ||||
12 | Accepted | 3ms | 2988 KiB | ||||
subtask3 | 0/28 | ||||||
13 | Accepted | 4ms | 3376 KiB | ||||
14 | Accepted | 4ms | 3264 KiB | ||||
15 | Runtime error | 4ms | 3668 KiB | ||||
16 | Runtime error | 3ms | 3344 KiB | ||||
17 | Wrong answer | 4ms | 3272 KiB | ||||
18 | Accepted | 4ms | 3276 KiB | ||||
19 | Accepted | 4ms | 3284 KiB | ||||
20 | Wrong answer | 4ms | 3272 KiB | ||||
21 | Runtime error | 3ms | 3356 KiB | ||||
subtask4 | 0/35 | ||||||
22 | Time limit exceeded | 1.1s | 8560 KiB | ||||
23 | Time limit exceeded | 1.075s | 8844 KiB | ||||
24 | Time limit exceeded | 1.07s | 8988 KiB | ||||
25 | Time limit exceeded | 1.082s | 9160 KiB | ||||
26 | Time limit exceeded | 1.074s | 6588 KiB | ||||
27 | Time limit exceeded | 1.062s | 10792 KiB | ||||
28 | Time limit exceeded | 1.059s | 10792 KiB | ||||
29 | Time limit exceeded | 1.075s | 10760 KiB | ||||
30 | Time limit exceeded | 1.078s | 11144 KiB | ||||
31 | Time limit exceeded | 1.067s | 9876 KiB | ||||
subtask5 | 0/25 | ||||||
32 | Time limit exceeded | 1.057s | 64972 KiB | ||||
33 | Time limit exceeded | 1.072s | 56112 KiB | ||||
34 | Time limit exceeded | 1.065s | 64360 KiB | ||||
35 | Time limit exceeded | 1.077s | 58872 KiB | ||||
36 | Time limit exceeded | 1.064s | 62376 KiB | ||||
37 | Time limit exceeded | 1.06s | 78180 KiB | ||||
38 | Time limit exceeded | 1.062s | 76728 KiB | ||||
39 | Time limit exceeded | 1.085s | 78308 KiB | ||||
40 | Time limit exceeded | 1.046s | 78180 KiB | ||||
41 | Time limit exceeded | 1.067s | 64700 KiB | ||||
42 | Time limit exceeded | 1.075s | 74992 KiB | ||||
43 | Time limit exceeded | 1.077s | 76464 KiB | ||||
44 | Time limit exceeded | 1.067s | 63200 KiB | ||||
45 | Time limit exceeded | 1.069s | 75348 KiB | ||||
46 | Time limit exceeded | 1.069s | 75172 KiB | ||||
47 | Time limit exceeded | 1.059s | 64704 KiB | ||||
48 | Time limit exceeded | 1.067s | 64876 KiB | ||||
49 | Time limit exceeded | 1.069s | 64768 KiB | ||||
50 | Time limit exceeded | 1.065s | 64744 KiB |