#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define er erase
#define pb push_back
#define ppb pop_back()
#define ph push
#define pp pop()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "YES" << "\n";
#define no cout << "NO" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
using namespace std;
ll fp(ll x , ll y)
{
if(y==0)
return 1;
ll z = fp(x,y/2);
if(y&1)
return z*z*x;
else
return z*z;
}
ll grid[1009][1009];
int main()
{
d3
ll h , w;
cin >> h >> w;
ll a[h];
ll b[w];
for(int i = 0 ; h>i ; i++)
cin >> a[i];
for(int i = 0 ; w>i ; i++)
cin >> b[i];
grid[0][0]=0;
for(int i = 1 ; h>i ; i++)
grid[i][0]=i*b[0];
for(int i = 1 ; w>i ; i++)
grid[0][i]=i*a[0];
for(int i = 1 ; h>i ; i++)
for(int j = 1 ; w>j ; j++)
grid[i][j]=min(grid[i-1][j]+b[j],grid[i][j-1]+a[i]);
cout << grid[h-1][w-1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
3 ms |
8268 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
4 ms |
8164 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8156 KB |
Output is correct |
17 |
Correct |
3 ms |
8280 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
472 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
4700 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
3 ms |
8268 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
4 ms |
8164 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8156 KB |
Output is correct |
17 |
Correct |
3 ms |
8280 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
472 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Incorrect |
1 ms |
4700 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |