Submission #867858

# Submission time Handle Problem Language Result Execution time Memory
867858 2023-10-29T16:00:16 Z ttamx Lightning Conductor (POI11_pio) C++14
27 / 100
266 ms 13328 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=5e5+5;
const int inf=1e9;

int n;
ll h[N],dp[N];

double 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],(ll)ceil(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"; 
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 5212 KB Output is correct
2 Correct 27 ms 5204 KB Output is correct
3 Incorrect 29 ms 5588 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 5724 KB Output is correct
2 Correct 47 ms 5568 KB Output is correct
3 Incorrect 45 ms 6228 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 117 ms 7504 KB Output is correct
2 Correct 114 ms 7252 KB Output is correct
3 Incorrect 108 ms 7880 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 10468 KB Output is correct
2 Correct 184 ms 8272 KB Output is correct
3 Incorrect 173 ms 10424 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 266 ms 13328 KB Output is correct
2 Correct 253 ms 10072 KB Output is correct
3 Incorrect 248 ms 13108 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 260 ms 10704 KB Output isn't correct
2 Halted 0 ms 0 KB -