Submission #867857

# Submission time Handle Problem Language Result Execution time Memory
867857 2023-10-29T15:58:00 Z ttamx Lightning Conductor (POI11_pio) C++14
27 / 100
258 ms 9296 KB
#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];

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],(int)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 2396 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 14 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2948 KB Output is correct
2 Correct 28 ms 2900 KB Output is correct
3 Incorrect 28 ms 3152 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 3060 KB Output is correct
2 Correct 46 ms 3056 KB Output is correct
3 Incorrect 50 ms 3716 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 116 ms 4176 KB Output is correct
2 Correct 110 ms 4176 KB Output is correct
3 Incorrect 108 ms 4692 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 182 ms 7196 KB Output is correct
2 Correct 178 ms 4948 KB Output is correct
3 Incorrect 172 ms 7100 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 258 ms 9296 KB Output is correct
2 Correct 252 ms 6140 KB Output is correct
3 Incorrect 251 ms 9168 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 257 ms 6740 KB Output isn't correct
2 Halted 0 ms 0 KB -