結果

問題 No.968 引き算をして門松列(その3)
ユーザー titiatitia
提出日時 2020-02-05 20:29:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,263 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 99,868 KB
最終ジャッジ日時 2023-10-24 05:36:13
合計ジャッジ時間 9,745 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
59,872 KB
testcase_01 AC 55 ms
66,224 KB
testcase_02 AC 59 ms
68,308 KB
testcase_03 AC 637 ms
87,108 KB
testcase_04 AC 766 ms
88,284 KB
testcase_05 AC 776 ms
88,004 KB
testcase_06 AC 750 ms
87,520 KB
testcase_07 AC 660 ms
86,920 KB
testcase_08 AC 899 ms
91,452 KB
testcase_09 AC 1,229 ms
99,472 KB
testcase_10 AC 1,263 ms
99,868 KB
testcase_11 AC 1,244 ms
99,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from itertools import product

def kado(A,B,C):
    if A>0 and B>0 and C>0 and A!=B and A!=C and B!=C and (max(A,B,C)==B or min(A,B,C)==B):
        return 1
    return 0

T=int(input())
for test in range(T):   
    A,B,C,X,Y,Z=map(int,input().split())
    S=sorted([A,B,C])
    CAN=[S[2]-S[1],S[2]-S[0],S[1]-S[0],0]
    CAN2=[]
    for i in CAN:
        for j in range(i,i+3):
            if j>=0:
                CAN2.append(j)

    P=list(product(CAN2,repeat=3))
    ANS=1<<63

    for x,y,z in P:
        if kado(A-x-z,B-x-y,C-y-z)==1:
            ANS=min(ANS,x*X+y*Y+z*Z)

    if ANS==1<<63:
        print(-1)
    else:
        print(ANS)
            
        
0