#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
const ll infinity = 1e18;
int main() {
int n, m;
cin >> n >> m;
vi dig1(m + n - 1);
for (int i = 0; i < m + n - 1; i++) {
cin >> dig1[i];
}
vi dig2(n + m - 1);
for (int i = 0; i < n + m - 1; i++) {
cin >> dig2[i];
}
ll ans = 0;
for (int i = 0; i < m; i++) {
ans += min(dig1[m - i - 1], dig2[i]);
}
// ll ans = infinity;
// for (int i = 0; i < (1 << (n + m - 1)); i++) {
// ll curr = 0;
// vb visit_dig1(n + m - 1);
// for (int j = 0; j < n + m - 1; j++) {
// if ((i >> j) & 1) {
// curr += dig1[j];
// visit_dig1[j] = true;
// }
// }
// vb visit_dig2(n + m - 1);
// for (int j = 0; j < n; j++) {
// for (int k = 0; k < m; k++) {
// if (!visit_dig1[j - k + m - 1]) {
// visit_dig2[j + k] = true;
// }
// }
// }
// for (int j = 0; j < n + m - 1; j++) {
// if (visit_dig2[j]) curr += dig2[j];
// }
// chkmin(ans, curr);
// }
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
3420 KB |
Output is correct |
2 |
Correct |
221 ms |
7244 KB |
Output is correct |
3 |
Correct |
176 ms |
7352 KB |
Output is correct |
4 |
Correct |
199 ms |
7528 KB |
Output is correct |
5 |
Correct |
210 ms |
7748 KB |
Output is correct |
6 |
Correct |
168 ms |
6696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
369 ms |
6548 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |