#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 |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
436 KB |
Output is correct |
4 |
Correct |
3 ms |
568 KB |
Output is correct |
5 |
Correct |
3 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3049 ms |
3852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
436 KB |
Output is correct |
4 |
Correct |
3 ms |
568 KB |
Output is correct |
5 |
Correct |
3 ms |
672 KB |
Output is correct |
6 |
Execution timed out |
3049 ms |
3852 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |