結果
問題 | No.2309 [Cherry 5th Tune D] 夏の先取り |
ユーザー |
|
提出日時 | 2023-05-19 23:28:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,647 bytes |
コンパイル時間 | 1,260 ms |
コンパイル使用メモリ | 127,972 KB |
最終ジャッジ日時 | 2025-02-13 03:10:32 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 35 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <cmath> #include <iomanip> #include <stack> #include <queue> #include <numeric> #include <map> #include <unordered_map> #include <set> #include <fstream> #include <chrono> #include <random> #include <bitset> //#include <atcoder/all> #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;} ll lcm(ll a, ll b) {return a/gcd(a,b)*b;} ll g(ll X, ll Y, ll A, ll C, ll B){ ll ans = 0; vector<ll> x = {A,B,0,A,0,B-C,A}; vector<ll> y = {0,0,C,B-A,B,C,C}; rep(i,7){ ll xx = x[i], yy = y[i]; if(xx>=0 && yy>=0 && xx<=A && yy<=C && xx+yy<=B){ chmax(ans,X*xx+Y*yy); } } return ans; } ll f(vector<ll> ABC, vector<ll> XYZ){ ll ans = 0; rep(i,3){ chmax(ans,g(XYZ[i],XYZ[(i+1)%3],ABC[i],ABC[(i+2)%3],ABC[(i+1)%3])); } return ans; } void solve(){ ll A,B,C; cin >> A >> B >> C; ll X,Y,Z,W; cin >> X >> Y >> Z >> W; ll mx3 = min({A,B,C}); ll ans = 0; for(ll s3=0;s3<=mx3;s3++){ ll ws = W*s3; ll a = A-s3; ll b = B-s3; ll c = C-s3; chmax(ans,ws+f({a,b,c},{X,Y,Z})); } cout << ans << '\n'; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--) solve(); return 0; }