結果

問題 No.967 引き算をして門松列(その2)
ユーザー 沙耶花沙耶花
提出日時 2020-01-13 20:53:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,474 bytes
コンパイル時間 1,832 ms
コンパイル使用メモリ 200,056 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 13:38:22
合計ジャッジ時間 2,640 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000



int main(){
	
	int T;
	cin>>T;
	
	for(int i=0;i<T;i++){
		long long A,B,C;
		long long X,Y,Z;
		cin>>A>>B>>C>>X>>Y>>Z;
		long long ans = Inf;
		if(A>B&&C>B){
			if(A==C){
				if(B+1==A){
					if(B==1)ans = -1;
					else{
						ans = min(X,Z)+Y;
						ans = min (ans,min(X,Z)*2);
					}
				}
				else{
					ans = min(X,Z);
				}
				
			}
			else{
				ans = 0;
			}
			cout<<ans<<endl;
			continue;
		}
		if(A<B&&C<B){
			if(A==C){
				if(A==1)ans = -1;
				else ans = min(X,Z);
			}
			else{
				ans = 0;
			}
			cout<<ans<<endl;
			continue;
		}
		if(A>C){
			swap(A,C);
			swap(X,Z);
		}
		
		int x = 0;
		if(A==B&&B==C){
			if(A<=2)ans = -1;
			else{
				ans = Y*2 + min(X,Z);
				ans = min(ans,max(X,Z)+min(X,Z)*2);
			}
		}
		else if(A==B){
			if(A==1)ans = -1;
			else{
				ans = Y;
				if(A>2)ans = min(ans,X + Z*(C-B+1) + min(X,Z));
			}
		}
		else if(B==C){
			if(B==1)ans = -1;
			else{
				if(A+1!=B)ans = Z;
				else{
					if(A==1)ans = -1;
					else{
						ans = Y*2;
						ans = min(Z*2,ans);
					}
	
				}
				if(A!=1){
					ans = min(ans,(B-A+1)*Y);
				}
			}
		}
		else{
			ans = Inf;
			if(A!=1)ans = min(ans,(B-A+1)*Y);
			if(B-A!=1)ans = min(ans,(C-B+1)*Z);
			else if(A!=1)ans = min(ans,(C-A+1)*Z);
			if(ans==Inf)ans = -1;
		}
		if(ans==Inf)ans = -1;
		cout<<ans<<endl;
	}

	return 0;
}
0