結果

問題 No.967 引き算をして門松列(その2)
ユーザー pluto77pluto77
提出日時 2020-06-13 13:17:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 7,840 KB
最終ジャッジ日時 2023-09-07 07:24:25
合計ジャッジ時間 2,421 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,756 KB
testcase_01 AC 16 ms
7,756 KB
testcase_02 AC 17 ms
7,808 KB
testcase_03 AC 67 ms
7,820 KB
testcase_04 AC 72 ms
7,820 KB
testcase_05 AC 71 ms
7,832 KB
testcase_06 AC 72 ms
7,808 KB
testcase_07 AC 73 ms
7,840 KB
testcase_08 AC 105 ms
7,796 KB
testcase_09 AC 160 ms
7,756 KB
testcase_10 AC 165 ms
7,836 KB
testcase_11 AC 160 ms
7,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki967
t=int(input())

for x in range(t):
 a=list(map(int,input().split()))
 res=float('inf')
 for i,j,k in [(0,2,1),(1,2,0),(1,0,2),(2,0,1)]:
  t1=max(a[j]-a[i]+1,0)
  aj= a[j]-t1
  t2=max(a[k]-aj+1,0)
  ak= a[k]-t2
  if ak>0:
   res=min(res,t1*a[j+3]+t2*a[k+3])
 if res==float('inf'):
  print(-1)
 else:
  print(res)
0