Files
python/GESP/Level5/GESP202409/20240901.cpp

30 lines
535 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], c[N];
/*
2 2
9 9
1 -1
参考答案:10
*/
int main() {
int n, m;
cin >> n >> m;
int mx = -1e9;
for (int i = 1; i <= n; i++) {
cin >> c[i];
mx = max(mx, c[i]);
}
for (int i = 1; i <= m; i++)
cin >> a[i];
for (int i = 1; i <= m;i++) { // 注意特殊情况,比如n=1,此时如果a[i]<0,那么就只能是减掉
if (n == 1 || a[i] > 0)
mx += a[i];
}
cout << mx << endl;
return 0;
}