#include <iostream>
using namespace std;
#define ll long long
const int N=1e4+100;
ll dp[N],a[N],pre[N],h[N],w[N];
ll cost(int i,int j)
{
if(i>j)
{
swap(i,j);
}
return pre[i-1]-pre[j]+((h[i]-h[j])*(h[i]-h[j]));
}
void solve()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>h[i];
for(int i=1;i<=n;i++)
{
cin>>w[i];
pre[i]=pre[i-1]+w[i];
}
ll ans=1e18;
for(int i=2;i<n;i++)
for(int j=i+1;j<n;j++)
ans=min(ans,cost(1,i)+cost(i,j)+cost(j,n));
cout<<ans<<endl;
}
signed main()
{
int t=1;
while(t--)
{
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
1480 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |