結果

問題 No.967 引き算をして門松列(その2)
ユーザー kotatsugamekotatsugame
提出日時 2020-01-18 02:10:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 72,684 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 12:26:15
合計ジャッジ時間 2,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 12 ms
4,384 KB
testcase_04 AC 11 ms
4,384 KB
testcase_05 AC 12 ms
4,384 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 14 ms
4,380 KB
testcase_08 AC 25 ms
4,384 KB
testcase_09 AC 32 ms
4,384 KB
testcase_10 AC 33 ms
4,380 KB
testcase_11 AC 32 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int T;
main()
{
	cin>>T;
	for(;T--;)
	{
		long A[3],C[3];
		for(int i=0;i<3;i++)cin>>A[i];
		for(int i=0;i<3;i++)cin>>C[i];
		long ans=9e18;
		vector<int>id={0,1,2};
		do{
			if(id[1]==1)continue;
			long a=A[id[0]],b=A[id[1]],c=A[id[2]];
			long now=0;
			if(b>=c)
			{
				now+=C[id[1]]*(b-c+1);
				b=c-1;
			}
			if(a>=b)
			{
				now+=C[id[0]]*(a-b+1);
				a=b-1;
			}
			if(a<=0)continue;
			ans=min(ans,now);
		}while(next_permutation(id.begin(),id.end()));
		if(ans>=6e18)ans=-1;
		cout<<ans<<endl;
	}
}
0