結果

問題 No.968 引き算をして門松列(その3)
ユーザー ぷらぷら
提出日時 2021-03-14 03:09:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 163,960 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 14:42:35
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
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;

long long solve(long long A,long long B,long long C,long long Y,long long Z) {
    long long tmp = 0;
    tmp += max(0LL,C-B+1)*Z;
    A -= max(0LL,C-B+1);
    C -= max(0LL,C-B+1);
    tmp += max(0LL,B-A+1)*Y;
    C -= max(0LL,B-A+1);
    B -= max(0LL,B-A+1);
    if(A <= 0 || B <= 0 || C <= 0) {
        return 1e18;
    }
    return tmp;
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        long long A,B,C,X,Y,Z;
        cin >> A >> B >> C >> X >> Y >> Z;
        long long ans = 1e18;
        // 2 1 3
        ans = min(ans,solve(B,A,C,X,Z));
        // 3 1 2
        ans = min(ans,solve(B,C,A,Z,X));
        // 2 3 1
        ans = min(ans,solve(C,A,B,X,Y));
        // 1 3 2
        ans = min(ans,solve(A,C,B,Z,Y));
        if(ans == 1e18) {
            cout << -1 << endl;
        }
        else {
            cout << ans << endl;
        }
    }
}
0