結果
問題 | No.968 引き算をして門松列(その3) |
ユーザー |
![]() |
提出日時 | 2020-01-13 22:06:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 797 ms / 2,000 ms |
コード長 | 1,594 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-12-23 00:55:46 |
合計ジャッジ時間 | 5,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 |
ソースコード
T=int(input())def check(A,B,C):if min(A,B,C)<=0:return 0if A==B or B==C or C==A:return 0if B==max(A,B,C) or B==min(A,B,C):return 1return 0for test in range(T):A,B,C,X,Y,Z=map(int,input().split())Y,Z=Z,Yif check(A,B,C)==1:print(0)continueif A==B==C:if A>=4:print(min(X+2*Z,Z+2*X,2*Y+X,2*Y+Z))else:print(-1)continueif A==C and B==A+1:if A>=5:print(min(Y+X,Y+Z,2*X+3*Z,2*Z+3*X))elif A>=3:print(min(Y+X,Y+Z))else:print(-1)continueANS=1<<60LA=[0,1]LB=[0,1]LC=[0,1]if B-C>=0:LA.append(B-C)LA.append(B-C+1)LA.append(B-C+2)if A-C>=0:LA.append(A-C)LA.append(A-C+1)LA.append(A-C+2)if A-B>=0:LB.append(A-B)LB.append(A-B+1)LB.append(A-B+2)if C-B>=0:LB.append(C-B)LB.append(C-B+1)LB.append(C-B+2)if B-A>=0:LC.append(B-A)LC.append(B-A+1)LC.append(B-A+2)if C-A>=0:LC.append(C-A)LC.append(C-A+1)LC.append(C-A+2)for la in LA:for lb in LB:for lc in LC:#print(la,lb,lc,check(A-la-lc,B-la-lb,C-lb-lc))if check(A-la-lb,B-la-lc,C-lb-lc)==1:ANS=min(ANS,la*X+lb*Y+lc*Z)if ANS==1<<60:print(-1)else:print(ANS)