結果

問題 No.968 引き算をして門松列(その3)
ユーザー vwxyzvwxyz
提出日時 2024-04-21 16:17:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 648 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-21 16:17:04
合計ジャッジ時間 3,753 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import itertools
T=int(input())
inf=1<<60
for t in range(T):
    A,B,C,Z,Y,X=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]=max(ABC[j],ABC[i]+1)
        cnt=[a-aa for a,aa in zip(ABC,(A,B,C))]
        ABC=[A,B,C]
        for i in range(3):
            for j in range(3):
                if i==j:
                    continue
                ABC[j]-=cnt[i]
        if min(ABC)>0:
            ans=min(ans,sum(c*x for c,x in zip(cnt,(X,Y,Z))))
    if ans==inf:
        ans=-1
    print(ans)

0