#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];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
34908 KB |
Output is correct |
2 |
Correct |
16 ms |
34780 KB |
Output is correct |
3 |
Correct |
16 ms |
34756 KB |
Output is correct |
4 |
Correct |
16 ms |
34908 KB |
Output is correct |
5 |
Correct |
15 ms |
34908 KB |
Output is correct |
6 |
Correct |
16 ms |
34948 KB |
Output is correct |
7 |
Correct |
17 ms |
34904 KB |
Output is correct |
8 |
Correct |
17 ms |
34908 KB |
Output is correct |
9 |
Correct |
17 ms |
35004 KB |
Output is correct |
10 |
Correct |
19 ms |
34904 KB |
Output is correct |
11 |
Correct |
20 ms |
34908 KB |
Output is correct |
12 |
Correct |
18 ms |
34908 KB |
Output is correct |
13 |
Correct |
18 ms |
34848 KB |
Output is correct |
14 |
Correct |
18 ms |
35004 KB |
Output is correct |
15 |
Correct |
18 ms |
35004 KB |
Output is correct |
16 |
Correct |
17 ms |
34908 KB |
Output is correct |
17 |
Correct |
17 ms |
34816 KB |
Output is correct |
18 |
Correct |
18 ms |
34908 KB |
Output is correct |
19 |
Correct |
17 ms |
34908 KB |
Output is correct |
20 |
Correct |
17 ms |
34764 KB |
Output is correct |
21 |
Correct |
16 ms |
34908 KB |
Output is correct |
22 |
Correct |
16 ms |
34908 KB |
Output is correct |
23 |
Correct |
20 ms |
34908 KB |
Output is correct |
24 |
Correct |
17 ms |
34904 KB |
Output is correct |
25 |
Correct |
17 ms |
34784 KB |
Output is correct |
26 |
Correct |
16 ms |
34908 KB |
Output is correct |
27 |
Correct |
17 ms |
34908 KB |
Output is correct |
28 |
Correct |
16 ms |
34764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
34908 KB |
Output is correct |
2 |
Correct |
17 ms |
34908 KB |
Output is correct |
3 |
Correct |
15 ms |
34880 KB |
Output is correct |
4 |
Runtime error |
65 ms |
70556 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
34908 KB |
Output is correct |
2 |
Correct |
16 ms |
34780 KB |
Output is correct |
3 |
Correct |
16 ms |
34756 KB |
Output is correct |
4 |
Correct |
16 ms |
34908 KB |
Output is correct |
5 |
Correct |
15 ms |
34908 KB |
Output is correct |
6 |
Correct |
16 ms |
34948 KB |
Output is correct |
7 |
Correct |
17 ms |
34904 KB |
Output is correct |
8 |
Correct |
17 ms |
34908 KB |
Output is correct |
9 |
Correct |
17 ms |
35004 KB |
Output is correct |
10 |
Correct |
19 ms |
34904 KB |
Output is correct |
11 |
Correct |
20 ms |
34908 KB |
Output is correct |
12 |
Correct |
18 ms |
34908 KB |
Output is correct |
13 |
Correct |
18 ms |
34848 KB |
Output is correct |
14 |
Correct |
18 ms |
35004 KB |
Output is correct |
15 |
Correct |
18 ms |
35004 KB |
Output is correct |
16 |
Correct |
17 ms |
34908 KB |
Output is correct |
17 |
Correct |
17 ms |
34816 KB |
Output is correct |
18 |
Correct |
18 ms |
34908 KB |
Output is correct |
19 |
Correct |
17 ms |
34908 KB |
Output is correct |
20 |
Correct |
17 ms |
34764 KB |
Output is correct |
21 |
Correct |
16 ms |
34908 KB |
Output is correct |
22 |
Correct |
16 ms |
34908 KB |
Output is correct |
23 |
Correct |
20 ms |
34908 KB |
Output is correct |
24 |
Correct |
17 ms |
34904 KB |
Output is correct |
25 |
Correct |
17 ms |
34784 KB |
Output is correct |
26 |
Correct |
16 ms |
34908 KB |
Output is correct |
27 |
Correct |
17 ms |
34908 KB |
Output is correct |
28 |
Correct |
16 ms |
34764 KB |
Output is correct |
29 |
Correct |
17 ms |
34908 KB |
Output is correct |
30 |
Correct |
17 ms |
34908 KB |
Output is correct |
31 |
Correct |
15 ms |
34880 KB |
Output is correct |
32 |
Runtime error |
65 ms |
70556 KB |
Execution killed with signal 11 |
33 |
Halted |
0 ms |
0 KB |
- |