結果

問題 No.967 引き算をして門松列(その2)
ユーザー tempura_pptempura_pp
提出日時 2020-01-13 20:34:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,092 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 96,556 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-21 16:21:14
合計ジャッジ時間 1,768 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
void solve(){
ll a,b,c;
cin>>a>>b>>c;
ll s,t,u;
cin>>s>>t>>u;
ll target[]={a-1,a,b-2,b-1,b,b+1,b+2,c-1,c};
ll ans = longinf;
rep(i,9)rep(j,9)rep(k,9){
ll x = target[i],y=target[j],z=target[k];
if(x>a||y>b||z>c)continue;
if(x<=0 ||y<= 0||z<=0)continue;
if(x==y||y==z||z==x)continue;
if(y>x && y>z) ans = min(ans,s*(a-x)+t*(b-y)+u*(c-z));
if(y<x && y<z) ans = min(ans,s*(a-x)+t*(b-y)+u*(c-z));
}
if(ans == longinf)cout<<-1<<endl;
else cout<<ans<<endl;
}
int main(){
int t;
cin>>t;
rep(i,t)solve();
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0