結果

問題 No.967 引き算をして門松列(その2)
ユーザー chocoruskchocorusk
提出日時 2020-01-13 20:50:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,334 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 109,868 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 13:30:34
合計ジャッジ時間 1,869 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
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 <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int t;
	cin>>t;
	const ll INF=2e18;
	for(int i=0; i<t; i++){
		ll a, b, c, x, y, z;
		cin>>a>>b>>c>>x>>y>>z;
		if(a>c) swap(a, c), swap(x, z);
		ll p=INF, q=INF;
		if(a<b){
			if(b<=c){
				if(a!=b-1) p=z*(c-b+1);
				else if(a>=2) p=min(z*(c-b+2), z*(c-b+1)+x);
			}else{
				if(a!=c) p=0;
				else if(a>=2) p=min(x, z);
			}
		}else if(a==b){
			if(a>=3) p=z*(c-a)+min(2*x+z, 2*z+x);
		}else{
			if(b>=3) p=x*(a-b+1)+z*(c-b+1)+min(x, z);
		}
		if(a<b){
			if(a>=2) q=y*(b-a+1);
		}else if(a>b){
			if(a!=c) q=0;
			else{
				if(a-b>=2) q=z*(c-a)+min(x, z);
				else if(b>=2) q=y+min(x, z);
			}
		}else{
			if(b!=c){
				if(a>=2) q=y;
			}else{
				if(b>=3) q=2*y+min(x, z);
			}
		}
		ll ans=min(p, q);
		if(ans==INF) cout<<-1<<endl;
		else cout<<ans<<endl;
		
	}
	return 0;
}
0