Submission #46977

#TimeUsernameProblemLanguageResultExecution timeMemory
46977dqhungdlBuilding Bridges (CEOI17_building)C++17
30 / 100
3049 ms3852 KiB
#include <bits/stdc++.h> using namespace std; int64_t n,a[100005],b[100005],f[100005]; int main() { ios_base::sync_with_stdio(false); //freopen("TEST.INP","r",stdin); cin>>n; for(int64_t i=1;i<=n;i++) cin>>a[i]; for(int64_t i=1;i<=n;i++) { cin>>b[i]; b[i]+=b[i-1]; } f[1]=0; for(int64_t i=2;i<=n;i++) { f[i]=1e18; for(int64_t j=1;j<i;j++) f[i]=min(f[i],f[j]+(a[i]-a[j])*(a[i]-a[j])+b[i-1]-b[j]); } cout<<f[n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...