結果
問題 | No.967 引き算をして門松列(その2) |
ユーザー | tanon710 |
提出日時 | 2020-05-04 23:08:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 231 ms / 2,000 ms |
コード長 | 1,128 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 82,324 KB |
実行使用メモリ | 78,720 KB |
最終ジャッジ日時 | 2024-06-25 02:36:45 |
合計ジャッジ時間 | 2,490 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 |
ソースコード
q=int(input()) for _ in range(q): a,b,c,x,y,z=map(int,input().split()) ans=10**18 #a<c<b tmp=[a,b,c] cost=0 if tmp[1]<=tmp[2]: cost+=(tmp[2]-tmp[1]+1)*z tmp[2]=tmp[1]-1 if tmp[0]>=tmp[2]: cost+=(tmp[0]-tmp[2]+1)*x tmp[0]=tmp[2]-1 if tmp[0]>0: ans=min(ans,cost) #c<a<b tmp=[a,b,c] cost=0 if tmp[0]>=tmp[1]: cost+=(tmp[0]-tmp[1]+1)*x tmp[0]=tmp[1]-1 if tmp[2]>=tmp[0]: cost+=(tmp[2]-tmp[0]+1)*z tmp[2]=tmp[0]-1 if tmp[2]>0: ans=min(ans,cost) #b<a<c tmp=[a,b,c] cost=0 if tmp[0]>=tmp[2]: cost+=(tmp[0]-tmp[2]+1)*x tmp[0]=tmp[2]-1 if tmp[1]>=tmp[0]: cost+=(tmp[1]-tmp[0]+1)*y tmp[1]=tmp[0]-1 if tmp[1]>0: ans=min(ans,cost) #b<c<a tmp=[a,b,c] cost=0 if tmp[2]>=tmp[0]: cost+=(tmp[2]-tmp[0]+1)*z tmp[2]=tmp[0]-1 if tmp[1]>=tmp[2]: cost+=(tmp[1]-tmp[2]+1)*y tmp[1]=tmp[2]-1 if tmp[1]>0: ans=min(ans,cost) if ans==10**18: print(-1) else: print(ans)