#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100000;
alignas(1024) ll a[MAXN], b[MAXN], dp[MAXN];
signed main(){
cin.tie(0)->sync_with_stdio(0);
int h, w; cin >> h >> w;
for (int i=0; i<h; i++){
cin >> a[i];
}
for (int j=0; j<w; j++){
cin >> b[j];
}
memset(dp, 0x3f, sizeof dp);
dp[0] = 0;
for (int i=0; i<h-1; i++){
for (int j=1; j<w; j++){
dp[j] = dp[j] < dp[j-1] + a[i] ? dp[j] : dp[j-1] + a[i];
}
for (int j=0; j<w; j++){
dp[j] += b[j];
}
}
for (int j=1; j<w; j++){
dp[j] = dp[j] < dp[j-1] + a[h-1] ? dp[j] : dp[j-1] + a[h-1];
}
cout << dp[w-1] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2672 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
3 ms |
2716 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
2 ms |
2652 KB |
Output is correct |
13 |
Correct |
2 ms |
2532 KB |
Output is correct |
14 |
Correct |
3 ms |
2652 KB |
Output is correct |
15 |
Correct |
2 ms |
2652 KB |
Output is correct |
16 |
Correct |
3 ms |
2532 KB |
Output is correct |
17 |
Correct |
2 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2652 KB |
Output is correct |
20 |
Correct |
1 ms |
2648 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
1 ms |
2512 KB |
Output is correct |
24 |
Correct |
1 ms |
2652 KB |
Output is correct |
25 |
Correct |
1 ms |
2652 KB |
Output is correct |
26 |
Correct |
1 ms |
2652 KB |
Output is correct |
27 |
Correct |
1 ms |
2652 KB |
Output is correct |
28 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2508 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
886 ms |
2992 KB |
Output is correct |
5 |
Correct |
19 ms |
3092 KB |
Output is correct |
6 |
Correct |
3 ms |
2652 KB |
Output is correct |
7 |
Execution timed out |
2065 ms |
3420 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2672 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
3 ms |
2716 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
2 ms |
2652 KB |
Output is correct |
13 |
Correct |
2 ms |
2532 KB |
Output is correct |
14 |
Correct |
3 ms |
2652 KB |
Output is correct |
15 |
Correct |
2 ms |
2652 KB |
Output is correct |
16 |
Correct |
3 ms |
2532 KB |
Output is correct |
17 |
Correct |
2 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2652 KB |
Output is correct |
20 |
Correct |
1 ms |
2648 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
1 ms |
2512 KB |
Output is correct |
24 |
Correct |
1 ms |
2652 KB |
Output is correct |
25 |
Correct |
1 ms |
2652 KB |
Output is correct |
26 |
Correct |
1 ms |
2652 KB |
Output is correct |
27 |
Correct |
1 ms |
2652 KB |
Output is correct |
28 |
Correct |
1 ms |
2652 KB |
Output is correct |
29 |
Correct |
1 ms |
2508 KB |
Output is correct |
30 |
Correct |
1 ms |
2652 KB |
Output is correct |
31 |
Correct |
1 ms |
2652 KB |
Output is correct |
32 |
Correct |
886 ms |
2992 KB |
Output is correct |
33 |
Correct |
19 ms |
3092 KB |
Output is correct |
34 |
Correct |
3 ms |
2652 KB |
Output is correct |
35 |
Execution timed out |
2065 ms |
3420 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |