#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;
const long long inf=1e17;
int n,m;
long long a[MAXN],b[MAXN];
long long dp[MAXN];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=m;i++){
cin>>b[i];
}
dp[1]=0;
for(int i=2;i<=max(n,m);i++){
dp[i]=inf;
for(int f=i-1;f>=1;f--){
dp[i]=min(dp[i],dp[f]+(i-f)*(a[i]+b[f]));
dp[i]=min(dp[i],dp[f]+(i-f)*(a[f]+b[i]));
}
}
cout<<dp[max(n,m)]<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
2 ms |
328 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |