結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー t98slidert98slider
提出日時 2023-05-19 22:13:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 3,000 ms
コード長 1,075 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 173,828 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 00:06:30
合計ジャッジ時間 4,671 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 22 ms
4,380 KB
testcase_02 AC 21 ms
4,380 KB
testcase_03 AC 16 ms
4,380 KB
testcase_04 AC 19 ms
4,376 KB
testcase_05 AC 15 ms
4,384 KB
testcase_06 AC 15 ms
4,376 KB
testcase_07 AC 17 ms
4,376 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 14 ms
4,384 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 17 ms
4,380 KB
testcase_13 AC 23 ms
4,376 KB
testcase_14 AC 14 ms
4,384 KB
testcase_15 AC 18 ms
4,376 KB
testcase_16 AC 14 ms
4,376 KB
testcase_17 AC 19 ms
4,376 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 AC 14 ms
4,384 KB
testcase_20 AC 16 ms
4,376 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 15 ms
4,380 KB
testcase_23 AC 15 ms
4,380 KB
testcase_24 AC 26 ms
4,380 KB
testcase_25 AC 18 ms
4,380 KB
testcase_26 AC 28 ms
4,380 KB
testcase_27 AC 16 ms
4,380 KB
testcase_28 AC 17 ms
4,380 KB
testcase_29 AC 19 ms
4,380 KB
testcase_30 AC 25 ms
4,376 KB
testcase_31 AC 61 ms
4,380 KB
testcase_32 AC 60 ms
4,380 KB
testcase_33 AC 60 ms
4,380 KB
testcase_34 AC 60 ms
4,380 KB
testcase_35 AC 59 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 65 ms
4,376 KB
testcase_42 AC 66 ms
4,380 KB
testcase_43 AC 23 ms
4,380 KB
testcase_44 AC 17 ms
4,380 KB
testcase_45 AC 17 ms
4,376 KB
testcase_46 AC 15 ms
4,380 KB
testcase_47 AC 8 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve(){
    ll ans = 0, w;
    vector<ll> a(3), b(3), c(3);
    for(auto &&v : a) cin >> v;
    for(auto &&v : b) cin >> v;
    cin >> w;
    vector<pair<int,int>> pa = {{0, 1}, {1, 2}, {2, 0}};
    int u, v;
    auto f = [&](){
        ll r = min(a[0], a[1]);
        r = min(r, a[2]);
        for(ll i = 0; i <= r; i++){
            do{
                ll tmp = max(i * w, (i / 2) * (b[0] + b[1] + b[2]) + (i & 1) * w);
                for(int j = 0; j < 3; j++) c[j] = a[j];
                for(int j = 0; j < 3; j++){
                    tie(u, v) = pa[j];
                    ll d = min(c[u], c[v]);
                    c[u] -= d, c[v] -= d;
                    tmp += d * b[u];
                }
                ans = max(ans, tmp);
            }while(next_permutation(pa.begin(), pa.end()));
            a[0]--, a[1]--, a[2]--;
        }
    };
    f();
    cout << ans << '\n';
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--) solve();
}
0