其他分享
首页 > 其他分享> > P2392 kkksc03考前临时抱佛脚

P2392 kkksc03考前临时抱佛脚

作者:互联网

// Problem: P2392 kkksc03考前临时抱佛脚
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P2392
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// User: Pannnn

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int s[4];
    for (int i = 0; i < 4; ++i) {
        cin >> s[i];
    }
    
    vector<vector<int>> info(4);
    for (int i = 0; i < 4; ++i) {
        info[i] = vector<int>(s[i]);
        for (int j = 0; j < info[i].size(); ++j) {
            cin >> info[i][j];
        }
    }
    
    int res = 0;
    for (int i = 0; i < 4; ++i) {
        int tmp = INT_MAX;
        for (int j = 0; j < (1 << info[i].size()); ++j) {
            int t1 = 0;
            int t2 = 0;
            for (int k = 0; k < info[i].size(); ++k) {
                if ((j & (1 << k)) == 0) {
                    t1 += info[i][k];
                } else {
                    t2 += info[i][k];
                }
            }
            tmp = min(max(t1, t2), tmp);
        }
        res += tmp;
    }
    cout << res << endl;
    return 0;
}

标签:info,P2392,考前,int,cin,++,Limit,kkksc03
来源: https://www.cnblogs.com/pannnn/p/15875933.html