結果
問題 | No.967 引き算をして門松列(その2) |
ユーザー |
![]() |
提出日時 | 2020-01-13 20:50:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 1,377 bytes |
コンパイル時間 | 2,407 ms |
コンパイル使用メモリ | 192,276 KB |
最終ジャッジ日時 | 2025-01-08 17:36:44 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef unsigned long long int ull;typedef long long int ll;typedef pair<ll,ll> pll;typedef long double D;//typedef complex<D> P;#define F first#define S secondconst ll MOD=1000000007;//const ll MOD=998244353;template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}const ll MX=2e18;ll solve1(ll A,ll B,ll C,ll X,ll Y,ll Z){ll ret=MX;ll bd=B;ll cd=min(C,B-1);ll ad=min(A,cd-1);if(ad>0 && bd>0 && cd>0){ret=min(ret,(A-ad)*X+(B-bd)*Y+(C-cd)*Z);}cd=C;ad=min(A,cd-1);bd=min(B,ad-1);if(ad>0 && bd>0 && cd>0){ret=min(ret,(A-ad)*X+(B-bd)*Y+(C-cd)*Z);}return ret;}ll solve2(ll A,ll B,ll C,ll X,ll Y,ll Z){ll ret=min(solve1(A,B,C,X,Y,Z),solve1(C,B,A,Z,Y,X));return ret==MX?-1LL:ret;}int main(){cin.tie(0);ios::sync_with_stdio(false);ll T;cin>>T;for(int i=0;i<T;i++){ll a,b,c,x,y,z;cin>>a>>b>>c>>x>>y>>z;cout<<solve2(a,b,c,x,y,z)<<endl;}return 0;}