Submission #132368

# Submission time Handle Problem Language Result Execution time Memory
132368 2019-07-18T18:37:27 Z Vardanyan Building Bridges (CEOI17_building) C++14
30 / 100
3 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
long long dp[N];
long long a[N];
long long b[N];
long long pref[N];
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1;i<=n;i++) cin>>a[i];
    for(int i = 1;i<=n;i++){
        cin>>b[i];
        pref[i] = pref[i-1]+b[i];
        dp[i] = 1000000000000000;
    }
    dp[1] = 0;
    for(int i = 2;i<=n;i++){
        for(int j = 1;j<i;j++){
            dp[i] = min(dp[i],dp[j]+(a[i]-a[j])*(a[i]-a[j])+pref[i-1]-pref[j]);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 372 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 3 ms 388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 372 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 3 ms 388 KB Output is correct
6 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -