#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_unlocked())<'0'); for(X-='0'; '0'<=(_=getchar_unlocked()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846
int n, a[500005], hi[500005], best, l2, l3, l4;
int main(){
scan(n);
fox(l, n){
scan(a[l]);
//a[l]=l;
best=max(best, a[l]);
for(l2=1, l3=l-1, l4=1; l3>=0; l3-=l2, l2+=2, l4++){
best=max(a[l3]+l4, best);
}
hi[l]=best;
}
best=0;
foxr(l, n){
best=max(best, a[l]);
for(l2=1, l3=l+1, l4=1; l3<n; l3+=l2, l2+=2, l4++){
best=max(a[l3]+l4, best);
}
hi[l]=max(hi[l], best);
}
fox(l, n){
printf("%i\n", hi[l]-a[l]);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
1424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
1424 KB |
Output is correct |
2 |
Correct |
38 ms |
1424 KB |
Output is correct |
3 |
Correct |
42 ms |
1564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
1812 KB |
Output is correct |
2 |
Correct |
80 ms |
1824 KB |
Output is correct |
3 |
Correct |
88 ms |
2348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
286 ms |
3488 KB |
Output is correct |
2 |
Correct |
283 ms |
3488 KB |
Output is correct |
3 |
Correct |
271 ms |
4012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
537 ms |
6844 KB |
Output is correct |
2 |
Correct |
530 ms |
6844 KB |
Output is correct |
3 |
Correct |
520 ms |
6844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
938 ms |
9444 KB |
Output is correct |
2 |
Correct |
926 ms |
9444 KB |
Output is correct |
3 |
Correct |
922 ms |
9516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
935 ms |
9516 KB |
Output is correct |
2 |
Correct |
955 ms |
9516 KB |
Output is correct |
3 |
Correct |
962 ms |
9516 KB |
Output is correct |