#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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
subtask2 | 0/12 | ||||||
3 | Accepted | 3ms | 2144 KiB | ||||
4 | Wrong answer | 3ms | 2372 KiB | ||||
5 | Wrong answer | 3ms | 2488 KiB | ||||
6 | Wrong answer | 3ms | 2700 KiB | ||||
7 | Wrong answer | 2ms | 2556 KiB | ||||
8 | Wrong answer | 3ms | 2692 KiB | ||||
9 | Wrong answer | 3ms | 2776 KiB | ||||
10 | Wrong answer | 3ms | 2988 KiB | ||||
11 | Wrong answer | 3ms | 3072 KiB | ||||
12 | Wrong answer | 3ms | 3072 KiB | ||||
subtask3 | 0/28 | ||||||
13 | Wrong answer | 3ms | 3372 KiB | ||||
14 | Wrong answer | 4ms | 3596 KiB | ||||
15 | Wrong answer | 3ms | 3472 KiB | ||||
16 | Wrong answer | 3ms | 3528 KiB | ||||
17 | Wrong answer | 4ms | 3796 KiB | ||||
18 | Accepted | 3ms | 3804 KiB | ||||
19 | Accepted | 4ms | 4072 KiB | ||||
20 | Wrong answer | 3ms | 4028 KiB | ||||
21 | Wrong answer | 3ms | 4040 KiB | ||||
subtask4 | 0/35 | ||||||
22 | Time limit exceeded | 1.1s | 8936 KiB | ||||
23 | Time limit exceeded | 1.062s | 10172 KiB | ||||
24 | Time limit exceeded | 1.054s | 10904 KiB | ||||
25 | Time limit exceeded | 1.062s | 12024 KiB | ||||
26 | Time limit exceeded | 1.054s | 10732 KiB | ||||
27 | Time limit exceeded | 1.065s | 13312 KiB | ||||
28 | Time limit exceeded | 1.041s | 13828 KiB | ||||
29 | Time limit exceeded | 1.057s | 14516 KiB | ||||
30 | Time limit exceeded | 1.065s | 15092 KiB | ||||
31 | Time limit exceeded | 1.08s | 16336 KiB | ||||
subtask5 | 0/25 | ||||||
32 | Time limit exceeded | 1.055s | 66464 KiB | ||||
33 | Time limit exceeded | 1.042s | 61696 KiB | ||||
34 | Time limit exceeded | 1.082s | 66368 KiB | ||||
35 | Time limit exceeded | 1.075s | 61724 KiB | ||||
36 | Time limit exceeded | 1.067s | 64440 KiB | ||||
37 | Time limit exceeded | 1.044s | 66340 KiB | ||||
38 | Time limit exceeded | 1.059s | 65384 KiB | ||||
39 | Time limit exceeded | 1.059s | 66428 KiB | ||||
40 | Time limit exceeded | 1.08s | 66496 KiB | ||||
41 | Time limit exceeded | 1.064s | 66228 KiB | ||||
42 | Time limit exceeded | 1.07s | 66560 KiB | ||||
43 | Time limit exceeded | 1.069s | 76868 KiB | ||||
44 | Time limit exceeded | 1.062s | 88532 KiB | ||||
45 | Time limit exceeded | 1.059s | 98160 KiB | ||||
46 | Time limit exceeded | 1.059s | 107900 KiB | ||||
47 | Time limit exceeded | 1.049s | 120696 KiB | ||||
48 | Time limit exceeded | 1.088s | 127748 KiB | ||||
49 | Time limit exceeded | 1.067s | 127764 KiB | ||||
50 | Time limit exceeded | 1.065s | 127536 KiB |