Submission #89369

#TimeUsernameProblemLanguageResultExecution timeMemory
89369semiautoBuilding Bridges (CEOI17_building)C++14
30 / 100
3010 ms2780 KiB
#include <bits/stdc++.h> using namespace std; int n,i,j; long long x,s[100001],h[100001],dp[100001]; int main() { cin>>n; for (i=1;i<=n;i++) cin>>h[i]; for (i=1;i<=n;i++) { cin>>x; s[i]=s[i-1]+x; dp[i]=100000000000000000; } dp[1]=0; for (i=2;i<=n;i++) for (j=1;j<i;j++) dp[i]=min(dp[i],dp[j]+s[i-1]-s[j]+h[i]*h[i]+h[j]*h[j]-2*h[i]*h[j]); cout<<dp[n]<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...