#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int n, m;
vector <ll> a(2e5, 0);
vector <ll> b(2e5, 0);
vector <vector <ll>> dp(2e3, vector <ll>(2e3, 1e18));
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
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][1] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i * j == 1) continue;
dp[i][j] = min(dp[i - 1][j] + b[j], dp[i][j - 1] + a[i]);
}
}
cout << dp[n][m];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
34904 KB |
Output is correct |
2 |
Correct |
16 ms |
34908 KB |
Output is correct |
3 |
Correct |
16 ms |
34904 KB |
Output is correct |
4 |
Correct |
18 ms |
35012 KB |
Output is correct |
5 |
Correct |
16 ms |
34908 KB |
Output is correct |
6 |
Correct |
17 ms |
34908 KB |
Output is correct |
7 |
Correct |
16 ms |
34908 KB |
Output is correct |
8 |
Correct |
16 ms |
35000 KB |
Output is correct |
9 |
Correct |
18 ms |
34908 KB |
Output is correct |
10 |
Correct |
19 ms |
34852 KB |
Output is correct |
11 |
Correct |
19 ms |
34908 KB |
Output is correct |
12 |
Correct |
23 ms |
34904 KB |
Output is correct |
13 |
Correct |
23 ms |
34904 KB |
Output is correct |
14 |
Correct |
20 ms |
34908 KB |
Output is correct |
15 |
Correct |
19 ms |
34928 KB |
Output is correct |
16 |
Correct |
20 ms |
34908 KB |
Output is correct |
17 |
Correct |
19 ms |
34792 KB |
Output is correct |
18 |
Correct |
18 ms |
34908 KB |
Output is correct |
19 |
Correct |
18 ms |
34908 KB |
Output is correct |
20 |
Correct |
18 ms |
34908 KB |
Output is correct |
21 |
Correct |
16 ms |
34908 KB |
Output is correct |
22 |
Correct |
17 ms |
34908 KB |
Output is correct |
23 |
Correct |
18 ms |
34964 KB |
Output is correct |
24 |
Correct |
17 ms |
34908 KB |
Output is correct |
25 |
Correct |
17 ms |
34828 KB |
Output is correct |
26 |
Correct |
18 ms |
34904 KB |
Output is correct |
27 |
Correct |
18 ms |
34908 KB |
Output is correct |
28 |
Correct |
17 ms |
34904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
34904 KB |
Output is correct |
2 |
Correct |
18 ms |
34908 KB |
Output is correct |
3 |
Correct |
18 ms |
34908 KB |
Output is correct |
4 |
Runtime error |
63 ms |
70900 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
34904 KB |
Output is correct |
2 |
Correct |
16 ms |
34908 KB |
Output is correct |
3 |
Correct |
16 ms |
34904 KB |
Output is correct |
4 |
Correct |
18 ms |
35012 KB |
Output is correct |
5 |
Correct |
16 ms |
34908 KB |
Output is correct |
6 |
Correct |
17 ms |
34908 KB |
Output is correct |
7 |
Correct |
16 ms |
34908 KB |
Output is correct |
8 |
Correct |
16 ms |
35000 KB |
Output is correct |
9 |
Correct |
18 ms |
34908 KB |
Output is correct |
10 |
Correct |
19 ms |
34852 KB |
Output is correct |
11 |
Correct |
19 ms |
34908 KB |
Output is correct |
12 |
Correct |
23 ms |
34904 KB |
Output is correct |
13 |
Correct |
23 ms |
34904 KB |
Output is correct |
14 |
Correct |
20 ms |
34908 KB |
Output is correct |
15 |
Correct |
19 ms |
34928 KB |
Output is correct |
16 |
Correct |
20 ms |
34908 KB |
Output is correct |
17 |
Correct |
19 ms |
34792 KB |
Output is correct |
18 |
Correct |
18 ms |
34908 KB |
Output is correct |
19 |
Correct |
18 ms |
34908 KB |
Output is correct |
20 |
Correct |
18 ms |
34908 KB |
Output is correct |
21 |
Correct |
16 ms |
34908 KB |
Output is correct |
22 |
Correct |
17 ms |
34908 KB |
Output is correct |
23 |
Correct |
18 ms |
34964 KB |
Output is correct |
24 |
Correct |
17 ms |
34908 KB |
Output is correct |
25 |
Correct |
17 ms |
34828 KB |
Output is correct |
26 |
Correct |
18 ms |
34904 KB |
Output is correct |
27 |
Correct |
18 ms |
34908 KB |
Output is correct |
28 |
Correct |
17 ms |
34904 KB |
Output is correct |
29 |
Correct |
17 ms |
34904 KB |
Output is correct |
30 |
Correct |
18 ms |
34908 KB |
Output is correct |
31 |
Correct |
18 ms |
34908 KB |
Output is correct |
32 |
Runtime error |
63 ms |
70900 KB |
Execution killed with signal 11 |
33 |
Halted |
0 ms |
0 KB |
- |