#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[n - 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 |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
177 ms |
3412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
373 ms |
6548 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |