#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846
int n, a[500005], hi[500005], best, v[500006];
int main(){
scan(n);
fox(l, n){
scan(a[l]);
v[l]=a[l];
best=max(best, a[l]);
for(int l2=0; l-l2*l2-1>=0; ++l2){
v[l-l2*l2-1]++;
best=max(v[l-l2*l2-1], best);
}
hi[l]=best;
}
best=0;
foxr(l, n){
v[l]=a[l];
best=max(best, a[l]);
for(int l2=0; l+l2*l2+1<n; ++l2){
v[l+l2*l2+1]++;
best=max(best, v[l+l2*l2+1]);
}
hi[l]=max(hi[l], best);
}
fox(l, n){
printf("%i\n", hi[l]-a[l]);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
1664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
2532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
3220 KB |
Output is correct |
2 |
Correct |
58 ms |
3272 KB |
Output is correct |
3 |
Correct |
56 ms |
4024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
111 ms |
5352 KB |
Output is correct |
2 |
Correct |
113 ms |
6156 KB |
Output is correct |
3 |
Correct |
104 ms |
7244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
392 ms |
11132 KB |
Output is correct |
2 |
Correct |
370 ms |
12980 KB |
Output is correct |
3 |
Correct |
364 ms |
14988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
723 ms |
21644 KB |
Output is correct |
2 |
Correct |
722 ms |
23112 KB |
Output is correct |
3 |
Correct |
738 ms |
27252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1069 ms |
30412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1081 ms |
35108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |