結果

問題 No.967 引き算をして門松列(その2)
ユーザー uni_pythonuni_python
提出日時 2020-10-01 23:18:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,764 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 79,572 KB
最終ジャッジ日時 2023-09-21 12:43:47
合計ジャッジ時間 2,626 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,344 KB
testcase_01 AC 70 ms
71,512 KB
testcase_02 AC 69 ms
71,348 KB
testcase_03 AC 154 ms
78,184 KB
testcase_04 AC 136 ms
78,036 KB
testcase_05 AC 138 ms
78,108 KB
testcase_06 AC 137 ms
77,932 KB
testcase_07 AC 137 ms
77,864 KB
testcase_08 AC 171 ms
78,088 KB
testcase_09 AC 166 ms
78,904 KB
testcase_10 AC 168 ms
78,644 KB
testcase_11 AC 193 ms
79,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    T=I()
    inf=10**20
    for _ in range(T):
        ans=inf
        a,b,c,x,y,z=MI()
        L=[a,b,c]
        
        # bが最大かつa,cが等しくない
        t=b-1
        temp=0
        if a>t:
            temp+=(a-t)*x
            a=t
        if c>t:        
            temp+=(c-t)*z
            c=t
        if a==c:
            if x<=z:
                a-=1
                temp+=x
            else:
                c-=1
                temp+=z
        if min(a,c)>=1:
            ans=min(ans,temp)
            
        # print(a,b,c,temp)
        a,b,c=L
            
        # bが最小かつa,cが等しくない
        t=min(L)
        temp=(b-t)*y
        b=t
        if a==b==c:
            b-=2
            if x<=z:
                a-=1
                temp+=2*y+x
            else:
                c-=1
                temp+=2*y+z
        
        elif a==b:
            b-=1
            temp+=y
        elif b==c:
            b-=1
            temp+=y
        elif a==c:
            if x<=z:
                a-=1
                temp+=x
                if a==b:
                    b-=1
                    temp+=y
            else:
                c-=1
                temp+=z
                if c==b:
                    b-=1
                    temp+=y
                
        if b>=1:
            ans=min(ans,temp)
            
        # print(a,b,c,temp)
            
                
        if ans==inf:
            print(-1)
        else:
            print(ans)
            
        
        
        
            
        
        


main()
0