Submission #87717

#TimeUsernameProblemLanguageResultExecution timeMemory
87717ioaneBuilding Bridges (CEOI17_building)C++14
30 / 100
3047 ms3916 KiB
//https://www.spoj.com/problems/EC_P/ //https://www.spoj.com/problems/tag/scc #include <bits/stdc++.h> #define F first #define S second #define I insert #define LL long long #define PB push_back #define MP make_pair const LL N=100005, mod=998244353; using namespace std; LL n, m, i, j, k, l, r, t, h[N], a[N], dp[N], sum; int main(){ ios::sync_with_stdio(false); cin>>n; for(i=0;i<n;i++)cin>>h[i]; for(i=0;i<n;i++)cin>>a[i]; for(i=1;i<n;i++){ sum=0;dp[i]=mod; for(j=i-1;j>=0;j--){ dp[i]=min(dp[i],dp[j]+sum+(h[i]-h[j])*(h[i]-h[j])); sum+=a[j]; } } cout<<dp[n-1]<<endl; return 0; } // IIIIIIIII OOOOO A NN N EEEEEEEEEE // I O O A A N N N E // I O O A A N N N E // I O O A A N N N E // I O O AAAAAAAAA N N N EEEEEEEE // I O O A A N N N E // I O O A A N N N E // I O O A A N N N E // IIIIIIIII OOOOO A A N NN EEEEEEEEEE ___ KAPANADZE
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...