結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー shobonvipshobonvip
提出日時 2023-05-19 22:39:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 269 ms / 3,000 ms
コード長 1,027 bytes
コンパイル時間 4,411 ms
コンパイル使用メモリ 259,352 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 00:35:00
合計ジャッジ時間 10,177 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,380 KB
testcase_01 AC 86 ms
4,376 KB
testcase_02 AC 77 ms
4,376 KB
testcase_03 AC 60 ms
4,376 KB
testcase_04 AC 70 ms
4,380 KB
testcase_05 AC 56 ms
4,380 KB
testcase_06 AC 53 ms
4,384 KB
testcase_07 AC 64 ms
4,376 KB
testcase_08 AC 73 ms
4,380 KB
testcase_09 AC 81 ms
4,376 KB
testcase_10 AC 51 ms
4,380 KB
testcase_11 AC 71 ms
4,380 KB
testcase_12 AC 67 ms
4,376 KB
testcase_13 AC 87 ms
4,376 KB
testcase_14 AC 49 ms
4,376 KB
testcase_15 AC 64 ms
4,380 KB
testcase_16 AC 43 ms
4,376 KB
testcase_17 AC 77 ms
4,380 KB
testcase_18 AC 81 ms
4,380 KB
testcase_19 AC 50 ms
4,380 KB
testcase_20 AC 61 ms
4,384 KB
testcase_21 AC 46 ms
4,380 KB
testcase_22 AC 50 ms
4,380 KB
testcase_23 AC 55 ms
4,380 KB
testcase_24 AC 97 ms
4,380 KB
testcase_25 AC 67 ms
4,376 KB
testcase_26 AC 108 ms
4,376 KB
testcase_27 AC 57 ms
4,376 KB
testcase_28 AC 61 ms
4,376 KB
testcase_29 AC 73 ms
4,380 KB
testcase_30 AC 98 ms
4,376 KB
testcase_31 AC 254 ms
4,380 KB
testcase_32 AC 255 ms
4,380 KB
testcase_33 AC 255 ms
4,376 KB
testcase_34 AC 253 ms
4,376 KB
testcase_35 AC 254 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 268 ms
4,376 KB
testcase_42 AC 269 ms
4,376 KB
testcase_43 AC 90 ms
4,376 KB
testcase_44 AC 63 ms
4,380 KB
testcase_45 AC 64 ms
4,376 KB
testcase_46 AC 54 ms
4,376 KB
testcase_47 AC 29 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

ll h2(int a, int b, int c, ll y, ll z){
	int targ1 = min(b, c);
	int targ2 = min(a, c-targ1);
	ll ret = y * targ1 + z * targ2;
	targ2 = min(a, c);
	targ1 = min(b, c-targ2);
	ret = max(ret, y * targ1 + z * targ2);
	return ret;
}

void solve(){
	int a, b, c; cin >> a >> b >> c;
	ll x, y, z, w; cin >> x >> y >> z >> w;
	ll ans = 0;
	for (int k=0; k<=min(a, min(b, c)); k++){
		ll tmp = w * k;
		int ub = min(a, b) - k;
		int lb = 0;
		while (ub - lb > 2){
			int t1 = (ub + 2 * lb) / 3;
			int t2 = (ub * 2 + lb) / 3;
			if (h2(a-k-t1, b-k-t1, c-k, y, z) + x * t1 < h2(a-k-t2, b-k-t2, c-k, y, z) + x * t2){
				lb = t1;
			}else{
				ub = t2;
			}
		}
		for (int t=lb; t<=ub; t++){
			ans = max(ans, tmp + h2(a-k-t, b-k-t, c-k, y, z) + x * t);
		}
	}
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int t; cin >> t;
	while(t--) solve();
}
0