結果
問題 | No.966 引き算をして門松列(その1) |
ユーザー |
![]() |
提出日時 | 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 sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesT = int(readline())m = map(int,read().split())ABC = zip(m,m,m)INF = 10 ** 18def type_231(A,B,C):a = B - 1if a > A:a = Ac = a - 1if c > C:c = Cif c <= 0:return INFreturn (A - a) + (C - c)def type_213(A,B,C):a = C - 1if a > A:a = Ab = a - 1if b > B:b = Bif b <= 0:return INFreturn (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 -1answer = [solve(a,b,c) for a,b,c in ABC]print('\n'.join(map(str,answer)))