結果

問題 No.967 引き算をして門松列(その2)
ユーザー furafura
提出日時 2020-05-28 23:12:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 2,512 ms
コンパイル使用メモリ 193,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 14:28:15
合計ジャッジ時間 2,794 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 11 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 10 ms
5,376 KB
testcase_07 AC 13 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 32 ms
5,376 KB
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

void solve(){
	lint a,b,c,x,y,z; cin>>a>>b>>c>>x>>y>>z;

	lint ans=LLONG_MAX;
	// b が最大
	if(b>=3 && !(a==1 && b==1)){
		lint ta=a,tc=c;

		lint res=0;
		if(a>=b) res+=x*(a-b+1), a=b-1;
		if(c>=b) res+=z*(c-b+1), c=b-1;
		if(a==c) res+=min(x,z);
		ans=min(ans,res);

		a=ta; c=tc;
	}
	// b が最小
	if(a>=2 && c>=2 &&!(a==2 && c==2)){
		lint res=0;
		if(a==c){
			res+=min(x,z);
			a--;
		}
		if(b>=min(a,c)) res+=y*(b-min(a,c)+1);
		ans=min(ans,res);
	}
	printf("%lld\n",ans<LLONG_MAX?ans:-1);
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}
0