結果
問題 | No.966 引き算をして門松列(その1) |
ユーザー |
![]() |
提出日時 | 2023-01-21 16:52:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 161 ms / 2,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 82,324 KB |
実行使用メモリ | 77,464 KB |
最終ジャッジ日時 | 2024-06-24 00:16:01 |
合計ジャッジ時間 | 1,373 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 |
ソースコード
def high(a, b, c): v = 0 if a >= b: v += a - b + 1 a = b - 1 if c >= b: v += c - b + 1 c = b - 1 if a == c: v += 1 a -= 1 if min(a, b, c) <= 0: return inf else: return v def low(a, b, c): v = 0 if a == c: v += 1 a -= 1 if b >= min(a, c): v += b - min(a, c) + 1 b = min(a, c) - 1 if min(a, b, c) <= 0: return inf else: return v T = int(input()) inf = 10 ** 18 for _ in range(T): A, B, C = map(int, input().split()) ans = min(high(A, B, C), low(A, B, C)) print(ans) if ans != inf else print(-1)