結果

問題 No.968 引き算をして門松列(その3)
ユーザー Y17Y17
提出日時 2020-01-13 21:52:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 144,388 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-24 16:17:42
合計ジャッジ時間 2,146 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long

int solve(int a, int b, int c, int x, int y){

    int ans = 0;

    if(b <= c){
        int num = (c+1)-b;
        if(a <= num || c <= num){
            return LLONG_MAX;
        }
        ans += num * y;
        a -= num;
        c -= num;
    }

    if(a <= b){
        int num = (b+1)-a;
        if(b <= num || c <= num){
            return LLONG_MAX;
        }
        ans += num * x;
    }

    return ans;
}

signed main(){
    int t;
    cin >> t;

    for(int i = 0;i < t;i++){
        int a, b, c, x, y, z;
        cin >> a >> b >> c >> x >> y >> z;

        int ans = min({solve(b, a, c, z, y), solve(b, c, a, x, y), solve(a, c, b, x, z), solve(c, a, b, y, z)});

        if(ans == LLONG_MAX){
            cout << -1 << endl;
        }else{
            cout << ans << endl;
        }
    }

    return 0;
}
0