結果

問題 No.968 引き算をして門松列(その3)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-20 23:53:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,030 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 82,412 KB
最終ジャッジ日時 2023-09-02 20:21:14
合計ジャッジ時間 4,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

inf = 10**30
# b > c > a 
def calc1(a,b,c,x,y,z):
    l = [a,b,c]
    count = [0,0,0]
    if a >= c:
        count[2] += (a-c+1)*z
        c = a+1
    if c >= b:
        count[1] += (c-b+1)*y
        b = c+1
    
    for i in range(3):
        for j in range(3):
            if i == j:
                continue
            l[j] -= count[i]
    if min(l) > 0:
        return sum(count)
    return inf

# c > a > b
def calc2(a,b,c,x,y,z):
   
    l = [a,b,c]
    count = [0,0,0]
    if b >= a:
        count[0] += (b-a+1)*x
        a = b+1
    if a >= c:
        count[2] += (a-c+1)*z
        c = a+1
    
    for i in range(3):
        for j in range(3):
            if i == j:
                continue
            l[j] -= count[i]
    if min(l) > 0:
        return sum(count)
    return inf

t = int(input())
for _ in range(t):
    a,b,c,x,y,z = map(int,input().split())
    x,y,z = y,z,x
    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