結果
問題 | No.2309 [Cherry 5th Tune D] 夏の先取り |
ユーザー |
![]() |
提出日時 | 2023-05-20 00:55:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 3,000 ms |
コード長 | 1,953 bytes |
コンパイル時間 | 1,867 ms |
コンパイル使用メモリ | 195,144 KB |
最終ジャッジ日時 | 2025-02-13 03:36:58 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) 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(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int T; ll A,B,C,X,Y,Z,W; ll ret; void hoge(ll x,ll y,ll z,ll w) { if(x>=0&&y>=0&&z>=0&&w>=0) ret=max(ret,x*X+y*Y+z*Z+w*W); } void solve() { int i,j,k,l,r,x,y; string s; cin>>T; while(T--) { cin>>A>>B>>C; cin>>X>>Y>>Z>>W; ret=0; FOR(i,3) { for(int a=0;a<=A;a++) { ll x,y,z,w; // Xを売らない // z+w=a // y +w=B // y+z+w=C w=a+B-C; z=a-w; y=B-w; hoge(0,y,z,w); // Yを売らない // x+z+w=a // x +w=B // z+w=C w=B+C-a; x=B-w; z=C-w; hoge(x,0,z,w); // Zを売らない // x +w=a // x+y+w=B // y+w=C w=a+C-B; x=a-w; y=C-w; hoge(x,y,0,w); // Wを売らない // x +z=a // x+y =B // y+z=C if((a+B+C)%2==0) { x=(a+B-C)/2; y=(-a+B+C)/2; z=(a-B+C)/2; hoge(x,y,z,0); } // Wを1個売る // x +z=a-1 // x+y =B-1 // y+z=C-1 if((a+B+C+3)%2==0&&a&&B&&C) { x=(a+B-C-1)/2; y=(-a+B+C-1)/2; z=(a-B+C-1)/2; hoge(x,y,z,1); } } swap(A,B); swap(B,C); swap(X,Y); swap(Y,Z); } cout<<ret<<endl; } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }