結果
| 問題 |
No.968 引き算をして門松列(その3)
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2020-01-13 20:48:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,124 bytes |
| コンパイル時間 | 2,181 ms |
| コンパイル使用メモリ | 194,552 KB |
| 最終ジャッジ日時 | 2025-01-08 17:35:31 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 9 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
const Int INF = 1e18;
Int p1_1(Int a,Int b,Int c,Int x,Int y,Int z){
// a < b > c, a < c < b
int res=0;
while(a>=c) a--,b--,res+=x;
while(c>=b) a--,c--,res+=z;
if(min({a,b,c})<=0) return INF;
return res;
}
Int p1(Int a,Int b,Int c,Int x,Int y,Int z){
// a < b > c
return min(p1_1(a,b,c,x,y,z),p1_1(c,b,a,z,y,x));
}
Int p2_1(Int a,Int b,Int c,Int x,Int y,Int z){
// a > b < c, b < a < c
int res=0;
while(b>=a) b--,c--,res+=y;
while(a>=c) a--,b--,res+=x;
if(min({a,b,c})<=0) return INF;
return res;
}
Int p2(Int a,Int b,Int c,Int x,Int y,Int z){
// a > b < c
return min(p2_1(a,b,c,x,y,z),p2_1(c,b,a,z,y,x));
}
signed solve(){
Int a,b,c,x,y,z;
cin>>a>>b>>c>>x>>y>>z;
Int ans=min(p1(a,b,c,x,y,z),p2(a,b,c,x,y,z));
if(ans==INF) ans=-1;
cout<<ans<<endl;
return 0;
}
signed main(){
Int T;
cin>>T;
while(T--) solve();
return 0;
}
beet