Submission #867861

# Submission time Handle Problem Language Result Execution time Memory
867861 2023-10-29T16:05:01 Z ttamx Lightning Conductor (POI11_pio) C++14
27 / 100
238 ms 9296 KB
#include<bits/stdc++.h>

using namespace std;

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

int n;
int h[N],dp[N];
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(h[i]+ceil(sqrt(mid-i))>h[opt]+ceil(sqrt(mid-opt)))opt=i;
    dp[mid]=max(dp[mid],h[opt]-h[mid]+(int)ceil(sqrt(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 0 ms 2396 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 13 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2956 KB Output is correct
2 Correct 25 ms 2908 KB Output is correct
3 Incorrect 27 ms 3152 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 3156 KB Output is correct
2 Correct 44 ms 3156 KB Output is correct
3 Incorrect 40 ms 3668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 101 ms 4184 KB Output is correct
2 Correct 100 ms 4056 KB Output is correct
3 Incorrect 97 ms 4876 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 160 ms 7252 KB Output is correct
2 Correct 157 ms 4944 KB Output is correct
3 Incorrect 156 ms 7252 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 230 ms 9128 KB Output is correct
2 Correct 228 ms 6136 KB Output is correct
3 Incorrect 220 ms 9296 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 238 ms 6656 KB Output isn't correct
2 Halted 0 ms 0 KB -