結果

問題 No.967 引き算をして門松列(その2)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-20 23:43:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 80,792 KB
最終ジャッジ日時 2023-09-02 20:02:54
合計ジャッジ時間 4,036 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,252 KB
testcase_01 AC 72 ms
71,272 KB
testcase_02 AC 72 ms
71,060 KB
testcase_03 AC 181 ms
78,544 KB
testcase_04 AC 168 ms
78,568 KB
testcase_05 AC 164 ms
78,860 KB
testcase_06 AC 166 ms
78,716 KB
testcase_07 AC 166 ms
78,680 KB
testcase_08 AC 217 ms
79,368 KB
testcase_09 AC 223 ms
79,576 KB
testcase_10 AC 214 ms
79,536 KB
testcase_11 AC 261 ms
80,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inf = 10**30
# b > c > a 
def calc1(a,b,c,x,y,z):

    count = 0
    if b <= c:
        count += (c-b+1)*z
        c = b-1
    if a >= c:
        count += (a-c+1)*x
        a = c-1
    if a > 0:
        return count
    return inf

# c > a > b
def calc2(a,b,c,x,y,z):
   
    count = 0
    if a >= c:
        count += (a-c+1)*x
        a = c-1
    if b >= a:
        count += (b-a+1)*y
        b = a-1
    if b > 0:
        return count
    return inf

t = int(input())
for _ in range(t):
    a,b,c,x,y,z = map(int,input().split())

    ans = min(calc1(a,b,c,x,y,z),calc2(a,b,c,x,y,z),calc1(c,b,a,z,y,x),calc2(c,b,a,z,y,x))
    if ans == inf:
        ans = -1
    print(ans)
0