結果
問題 |
No.3173 じゃんけんの勝ちの回数
|
ユーザー |
|
提出日時 | 2025-06-06 23:19:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,504 bytes |
コンパイル時間 | 2,178 ms |
コンパイル使用メモリ | 198,860 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-06 23:19:27 |
合計ジャッジ時間 | 5,198 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ vector<int> A(3),B(3); for(auto &a : A) cin >> a; for(auto &b : B) cin >> b; rotate(A.begin(),A.begin()+2,A.end()); int maxa = 0,mina = 1e9; for(int i=0; i<3; i++) maxa += min(A.at(i),B.at(i)); rotate(A.begin(),A.begin()+1,A.end()); vector<int> P = {0,1,2}; do{ for(int S=0; S<8; S++){ vector<int> C = A,D = B; for(int i=0; i<3; i++){ int p = P.at(i); if(S&(1<<i)){ int dec = min(C.at(p),D.at(p)); C.at(p) -= dec,D.at(p) -= dec; dec = min(C.at(p),D.at((p+2)%3)); C.at(p) -= dec,D.at((p+2)%3) -= dec; } else{ int dec = min(C.at(p),D.at((p+2)%3)); C.at(p) -= dec,D.at((p+2)%3) -= dec; dec = min(C.at(p),D.at(p)); C.at(p) -= dec,D.at(p) -= dec; } } int now = 0; for(auto c : C) now += c; mina = min(mina,now); } }while(next_permutation(P.begin(),P.end())); cout << mina << " " << maxa << "\n"; } }