結果

問題 No.967 引き算をして門松列(その2)
ユーザー vwxyzvwxyz
提出日時 2024-04-21 16:00:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 79,376 KB
最終ジャッジ日時 2024-04-21 16:00:27
合計ジャッジ時間 3,233 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
52,236 KB
testcase_01 AC 48 ms
52,420 KB
testcase_02 AC 48 ms
53,128 KB
testcase_03 AC 256 ms
79,096 KB
testcase_04 AC 242 ms
78,988 KB
testcase_05 AC 225 ms
79,260 KB
testcase_06 AC 226 ms
79,376 KB
testcase_07 AC 139 ms
76,880 KB
testcase_08 AC 158 ms
76,904 KB
testcase_09 AC 200 ms
77,416 KB
testcase_10 AC 180 ms
76,840 KB
testcase_11 AC 211 ms
77,124 KB
権限があれば一括ダウンロードができます

ソースコード

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