結果
| 問題 |
No.967 引き算をして門松列(その2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-28 23:12:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 683 bytes |
| コンパイル時間 | 2,414 ms |
| コンパイル使用メモリ | 191,296 KB |
| 最終ジャッジ日時 | 2025-01-10 16:06:29 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 7 WA * 3 |
コンパイルメッセージ
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 && b==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;
}