結果
問題 | No.2309 [Cherry 5th Tune D] 夏の先取り |
ユーザー |
|
提出日時 | 2023-05-19 22:10:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,024 bytes |
コンパイル時間 | 1,893 ms |
コンパイル使用メモリ | 175,568 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-18 02:52:58 |
合計ジャッジ時間 | 3,997 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 35 |
ソースコード
#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 = i * 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(); }