結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー houren
提出日時 2023-05-19 23:47:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,338 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 173,716 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-20 02:52:04
合計ジャッジ時間 9,690 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);

ll f(vector<ll> a, vector<ll> x, vector<int> p){
    ll res = 0;
    rep(j,2){
        ll k = min(a[p[j]], a[(p[j]+1)%3]);
        res += k * x[p[j]];
        a[p[j]] -= k;
        a[p[(j+1)%3]] -= k;
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    vector<int> p(3);
    rep(houren,t){
        vector<ll> a(3), x(3);
        ll w;
        rep(i,3) cin >> a[i];
        rep(i,3) cin >> x[i];
        cin >> w;
        ll ans = 0;
        bool ok = true;
        for(ll i=0;ok;i++){
            rep(j,3) p[j] = j;
            do{
                chmax(ans, w*i+f(a,x,p));
            }while(next_permutation(all(p)));
            rep(j,3){
                a[j]--;
                if(a[j]<0) ok = false;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}
0