#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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2064 KiB | ||||
subtask2 | 12/12 | ||||||
3 | Accepted | 3ms | 2284 KiB | ||||
4 | Accepted | 3ms | 2452 KiB | ||||
5 | Accepted | 3ms | 2676 KiB | ||||
6 | Accepted | 3ms | 2768 KiB | ||||
7 | Accepted | 3ms | 2976 KiB | ||||
8 | Accepted | 3ms | 3184 KiB | ||||
9 | Accepted | 3ms | 3404 KiB | ||||
10 | Accepted | 3ms | 3484 KiB | ||||
11 | Accepted | 3ms | 3604 KiB | ||||
12 | Accepted | 3ms | 3696 KiB | ||||
subtask3 | 28/28 | ||||||
13 | Accepted | 3ms | 3724 KiB | ||||
14 | Accepted | 3ms | 3984 KiB | ||||
15 | Accepted | 3ms | 3940 KiB | ||||
16 | Accepted | 3ms | 3940 KiB | ||||
17 | Accepted | 3ms | 3944 KiB | ||||
18 | Accepted | 3ms | 4348 KiB | ||||
19 | Accepted | 3ms | 4364 KiB | ||||
20 | Accepted | 3ms | 4432 KiB | ||||
21 | Accepted | 3ms | 4328 KiB | ||||
subtask4 | 0/35 | ||||||
22 | Time limit exceeded | 1.1s | 6864 KiB | ||||
23 | Time limit exceeded | 1.054s | 6760 KiB | ||||
24 | Time limit exceeded | 1.062s | 6884 KiB | ||||
25 | Time limit exceeded | 1.057s | 6964 KiB | ||||
26 | Time limit exceeded | 1.077s | 5644 KiB | ||||
27 | Time limit exceeded | 1.054s | 6820 KiB | ||||
28 | Time limit exceeded | 1.049s | 6908 KiB | ||||
29 | Time limit exceeded | 1.085s | 6876 KiB | ||||
30 | Time limit exceeded | 1.057s | 6828 KiB | ||||
31 | Time limit exceeded | 1.065s | 6824 KiB | ||||
subtask5 | 0/25 | ||||||
32 | Time limit exceeded | 1.072s | 35032 KiB | ||||
33 | Time limit exceeded | 1.042s | 31912 KiB | ||||
34 | Time limit exceeded | 1.074s | 35048 KiB | ||||
35 | Time limit exceeded | 1.057s | 31988 KiB | ||||
36 | Time limit exceeded | 1.057s | 33828 KiB | ||||
37 | Time limit exceeded | 1.074s | 35212 KiB | ||||
38 | Time limit exceeded | 1.067s | 34468 KiB | ||||
39 | Time limit exceeded | 1.065s | 35104 KiB | ||||
40 | Time limit exceeded | 1.065s | 35028 KiB | ||||
41 | Time limit exceeded | 1.078s | 35048 KiB | ||||
42 | Time limit exceeded | 1.054s | 34008 KiB | ||||
43 | Time limit exceeded | 1.065s | 34600 KiB | ||||
44 | Time limit exceeded | 1.05s | 35180 KiB | ||||
45 | Time limit exceeded | 1.065s | 35100 KiB | ||||
46 | Time limit exceeded | 1.07s | 35280 KiB | ||||
47 | Time limit exceeded | 1.052s | 35376 KiB | ||||
48 | Time limit exceeded | 1.075s | 35476 KiB | ||||
49 | Time limit exceeded | 1.085s | 35588 KiB | ||||
50 | Time limit exceeded | 1.065s | 35532 KiB |