結果

問題 No.3173 じゃんけんの勝ちの回数
ユーザー 回転
提出日時 2025-06-18 01:06:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 615 ms / 2,000 ms
コード長 1,550 bytes
コンパイル時間 4,277 ms
コンパイル使用メモリ 280,500 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-18 01:06:36
合計ジャッジ時間 24,552 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
from itertools import permutations
T = int(input())

def get_min(a,b):
    ok = [(0,2),(1,0),(2,1),(0,0),(1,1),(2,2)]
    
    ret = 10**9
    for oks in permutations(ok):
        now_a = a[:];now_b = b[:]
        for c,d in oks:
            v = min(now_a[c],now_b[d])
            now_a[c] -= v;now_b[d] -= v
        ret = min(ret,sum(now_a))
    return ret

for _ in range(T):
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    MAX = 0
    MAX += min(A[0],B[1])
    MAX += min(A[1],B[2])
    MAX += min(A[2],B[0])

    MIN = get_min(A,B)
    print(MIN,MAX)
*/
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;

int get_min(vector<int> a, vector<int> b) {
    vector<pair<int, int>> ok = {{0, 2}, {1, 0}, {2, 1}, {0, 0}, {1, 1}, {2, 2}};
    int ret = INF;

    do {
        vector<int> now_a = a, now_b = b;
        for (auto [c, d] : ok) {
            int v = min(now_a[c], now_b[d]);
            now_a[c] -= v;
            now_b[d] -= v;
        }
        ret = min(ret, accumulate(now_a.begin(), now_a.end(), 0));
    } while (next_permutation(ok.begin(), ok.end()));

    return ret;
}

int main() {
    int T;
    cin >> T;

    while (T--) {
        vector<int> A(3), B(3);
        for (int i = 0; i < 3; i++) cin >> A[i];
        for (int i = 0; i < 3; i++) cin >> B[i];

        int MAX = 0;
        MAX += min(A[0], B[1]);
        MAX += min(A[1], B[2]);
        MAX += min(A[2], B[0]);

        int MIN = get_min(A, B);
        cout << MIN << " " << MAX << endl;
    }

    return 0;
}
0