题目传送门

懒得搬题面了qwq


题目解析

// 解析我也摸鱼了

AC 代码

#include<iostream>
#include<algorithm>
using namespace std;
const int N = 111;
int T;
bool com(int a, int b){
    return a > b;
}
int main(){
    cin >> T;
       while(T--){
        int red[N] = {0}, blue[N] = {0}; //储存红球和蓝球的个数
        int sr[N] = {0}, sb[N] = {0}; //求前缀和
        int r, b;
        cin >> r;
        for(int i = 1; i <= r; i++){
            cin >> red[i];
            sr[i] = red[i] + sr[i - 1];
        }
        cin >> b;
        for(int i = 1; i <= b; i++){
            cin >> blue[i];
            sb[i] = blue[i] + sb[i - 1];
        }
        sort(sr, sr + r + 1, com), sort(sb, sb + b + 1, com);//求出红球和蓝球各自的max
        int ans = sr[0] + sb[0];
        cout << max(ans, 0) << endl; //最小值不能小于0
    }

    return 0;
}