# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
221875 | 2020-04-11T11:35:58 Z | MKopchev | Building Bridges (CEOI17_building) | C++14 | 3000 ms | 4108 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=1e5+42; int n; long long h[nmax],w[nmax],pref[nmax]; long long dp[nmax]; int main() { scanf("%i",&n); for(int i=1;i<=n;i++)scanf("%lld",&h[i]); for(int i=1;i<=n;i++)scanf("%lld",&w[i]); for(int i=1;i<=n;i++)pref[i]=pref[i-1]+w[i]; dp[1]=0; for(int j=2;j<=n;j++) { dp[j]=1e18; for(int i=j-1;i>=1;i--) { long long s_1=h[j]*h[j]+pref[j-1]; long long s_2=h[i]*h[i]-pref[i]+dp[i]; long long s_3=-2*h[i]*h[j]; dp[j]=min(dp[j],s_1+s_2+s_3); } //cout<<j<<" -> "<<dp[j]<<endl; } printf("%lld\n",dp[n]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 384 KB | Output is correct |
5 | Correct | 6 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3072 ms | 4108 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 384 KB | Output is correct |
5 | Correct | 6 ms | 384 KB | Output is correct |
6 | Execution timed out | 3072 ms | 4108 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |