結果
問題 |
No.967 引き算をして門松列(その2)
|
ユーザー |
|
提出日時 | 2020-03-31 15:23:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,335 bytes |
コンパイル時間 | 1,482 ms |
コンパイル使用メモリ | 168,104 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 17:19:18 |
合計ジャッジ時間 | 2,540 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | WA * 10 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; typedef long long ll; typedef pair<int,int> pp; const int INF = 1e9; const int MOD = 1000000007; int main() { int t; cin >> t; auto f = [](int cen,int l,int r,ll x,ll y,ll z){ ll res = 0; if( l > r) {swap(l,r);swap(y,z);} if(l == r && r == cen){ l -= 2; cen --; res += 2*y + x; } if(l == r){ l -= 2; res += 2*y; } if(l == r-1){ l --; res += y; } if( r <= cen){ res += (cen - r + 1)*x; cen = r -1; } if( cen <= l){ res += (l - cen + 1)*y; l = cen - 1; } if( cen <= 0 || l <= 0 || r <= 0){ return (ll)(-1); }else{ return res; } }; rep(i,t){ int a,b,c; ll x,y,z; cin >> a >> b >> c >>x >> y >> z; ll res_a = f(a,b,c,x,y,z); ll res_b = f(c,a,b,z,x,y); if(res_a == -1 && res_b == -1) cout << -1 << endl; else if(res_a == -1) cout << res_b << endl; else if(res_b == -1) cout << res_a << endl; else cout << min(res_a,res_b) << endl; } return 0; }