結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-13 20:35:59 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 742 bytes |
| コンパイル時間 | 121 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 12,632 KB |
| 最終ジャッジ日時 | 2024-12-21 16:22:25 |
| 合計ジャッジ時間 | 859 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
T = int(readline())
m = map(int,read().split())
ABC = zip(m,m,m)
INF = 10 ** 18
def type_231(A,B,C):
a = B - 1
if a > A:
a = A
c = a - 1
if c > C:
c = C
if c <= 0:
return INF
return (A - a) + (C - c)
def type_213(A,B,C):
a = C - 1
if a > A:
a = A
b = a - 1
if b > B:
b = B
if b <= 0:
return INF
return (A - a) + (B - b)
def solve(A,B,C):
x = min(type_231(A,B,C), type_231(C,B,A), type_213(A,B,C), type_213(C,B,A))
return x if x < INF else -1
answer = [solve(a,b,c) for a,b,c in ABC]
print('\n'.join(map(str,answer)))
maspy