結果
| 問題 |
No.968 引き算をして門松列(その3)
|
| コンテスト | |
| ユーザー |
msm1993
|
| 提出日時 | 2020-04-03 15:46:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 2,000 ms |
| コード長 | 702 bytes |
| コンパイル時間 | 645 ms |
| コンパイル使用メモリ | 74,236 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 00:48:20 |
| 合計ジャッジ時間 | 1,811 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#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];
cin>>C[2]>>C[0]>>C[1];
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;
long X=0,Y=0;
if(a>=b)
{
now+=C[id[1]]*(a-b+1);
X=a-b+1;
b=a+1;
}
if(b>=c)
{
now+=C[id[2]]*(b-c+1);
Y=b-c+1;
c=b+1;
}
a=A[id[0]],b=A[id[1]],c=A[id[2]];
a-=X+Y;
b-=Y;
c-=X;
if(a<=0||b<=0||c<=0)continue;
ans=min(ans,now);
}while(next_permutation(id.begin(),id.end()));
if(ans>=6e18)ans=-1;
cout<<ans<<endl;
}
}
msm1993