#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[2000][2000];
int a[2000],b[2000];
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int h,w;
cin>>h>>w;
for(int i=0;i<=h;i++)
for(int j=0;j<=w;j++)
dp[i][j]=1e9;
dp[1][1]=0;
for(int i=1;i<=h;i++)
cin>>a[i];
for(int i=1;i<=w;i++)
cin>>b[i];
for(int i=1;i<=h;i++)
for(int j=1;j<=w;j++)
{
dp[i][j]=min(dp[i][j],dp[i-1][j]+b[j]);
dp[i][j]=min(dp[i][j],dp[i][j-1]+a[i]);
}
cout<<dp[h][w];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 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 |
Correct |
3 ms |
4564 KB |
Output is correct |
4 |
Runtime error |
47 ms |
63916 KB |
Execution killed with signal 11 |
5 |
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 |
1 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |