結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー 👑 kmjpkmjp
提出日時 2023-05-20 00:49:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,944 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 199,364 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 03:28:07
合計ジャッジ時間 5,189 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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) {
					x=(a+B-C-3)/2;
					y=(-a+B+C-3)/2;
					z=(a-B+C-3)/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;
}
0