This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |