結果
問題 | No.967 引き算をして門松列(その2) |
ユーザー |
|
提出日時 | 2020-05-29 00:04:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 1,859 ms |
コンパイル使用メモリ | 193,152 KB |
最終ジャッジ日時 | 2025-01-10 16:06:53 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:38:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | int q; scanf("%d",&q); rep(_,q) solve(); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; void solve(){ lint a,b,c,x,y,z; cin>>a>>b>>c>>x>>y>>z; lint ans=LLONG_MAX; // b が最大 if(b>=3 && !(a==1 && c==1)){ lint ta=a,tc=c; lint res=0; if(a>=b) res+=x*(a-b+1), a=b-1; if(c>=b) res+=z*(c-b+1), c=b-1; if(a==c) res+=min(x,z); ans=min(ans,res); a=ta; c=tc; } // b が最小 if(a>=2 && c>=2 && !(a==2 && c==2)){ lint res=0; if(a==c){ res+=min(x,z); a--; } if(b>=min(a,c)) res+=y*(b-min(a,c)+1); ans=min(ans,res); } printf("%lld\n",ans<LLONG_MAX?ans:-1); } int main(){ int q; scanf("%d",&q); rep(_,q) solve(); return 0; }