結果

問題 No.967 引き算をして門松列(その2)
ユーザー titiatitia
提出日時 2020-02-05 20:27:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 81,564 KB
実行使用メモリ 99,468 KB
最終ジャッジ日時 2023-10-24 05:33:51
合計ジャッジ時間 9,079 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
59,868 KB
testcase_01 WA -
testcase_02 AC 63 ms
70,356 KB
testcase_03 WA -
testcase_04 AC 738 ms
88,272 KB
testcase_05 AC 722 ms
88,148 KB
testcase_06 AC 741 ms
87,656 KB
testcase_07 AC 627 ms
87,120 KB
testcase_08 AC 832 ms
91,364 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

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,B-y,C-z)==1:
            ANS=min(ANS,x*X+y*Y+z*Z)

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