結果

問題 No.967 引き算をして門松列(その2)
ユーザー vwxyz
提出日時 2024-04-21 16:00:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 82,124 KB
実行使用メモリ 79,320 KB
最終ジャッジ日時 2024-10-13 14:57:35
合計ジャッジ時間 2,937 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
T=int(input())
inf=1<<60
for t in range(T):
    A,B,C,X,Y,Z=map(int,input().split())
    ans=inf
    for tpl in itertools.permutations(range(3)):
        if tpl[1]==1:
            continue
        ABC=[A,B,C]
        for i,j in zip(tpl,tpl[1:]):
            ABC[j]=min(ABC[j],ABC[i]-1)
        if min(ABC)>0:
            ans=min(ans,sum((a-aa)*x for a,aa,x in zip((A,B,C),ABC,(X,Y,Z))))
    if ans==inf:
        ans=-1
    print(ans)
0