#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> p2;
const int N=5e5+5;
const int inf=1e9;
int n;
int h[N],dp[N];
int calc(int i,int j){
return h[j]+ceil(sqrt(abs(i-j)))-h[i];
}
void solve(int l,int r,int optl,int optr){
if(l>r)return;
int mid=(l+r)/2;
int opt=optl;
for(int i=optl;i<=min(mid,optr);i++)if(calc(mid,opt)<calc(mid,i))opt=i;
dp[mid]=max(dp[mid],calc(mid,opt));
solve(l,mid-1,optl,opt);
solve(mid+1,r,opt,optr);
}
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i=1;i<=n;i++)cin >> h[i];
for(int t=0;t<2;t++){
solve(1,n,1,n);
reverse(h+1,h+n+1);
reverse(dp+1,dp+n+1);
}
for(int i=1;i<=n;i++)cout << dp[i] << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
2888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
3152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
2760 KB |
Output is correct |
2 |
Correct |
28 ms |
2908 KB |
Output is correct |
3 |
Incorrect |
29 ms |
2948 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
3156 KB |
Output is correct |
2 |
Correct |
54 ms |
3040 KB |
Output is correct |
3 |
Incorrect |
45 ms |
3668 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
114 ms |
4316 KB |
Output is correct |
2 |
Correct |
112 ms |
4184 KB |
Output is correct |
3 |
Incorrect |
114 ms |
4688 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
180 ms |
7100 KB |
Output is correct |
2 |
Correct |
185 ms |
5056 KB |
Output is correct |
3 |
Incorrect |
179 ms |
7104 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
263 ms |
9216 KB |
Output is correct |
2 |
Correct |
261 ms |
6224 KB |
Output is correct |
3 |
Incorrect |
252 ms |
9208 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
266 ms |
6912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |