結果
問題 |
No.966 引き算をして門松列(その1)
|
ユーザー |
![]() |
提出日時 | 2020-01-14 21:18:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 460 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 77,568 KB |
最終ジャッジ日時 | 2024-12-26 10:41:14 |
合計ジャッジ時間 | 2,060 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 2 |
ソースコード
import sys input = sys.stdin.readline def main(): T = int(input()) for _ in range(T): ans = 0 A, B, C = map(int, input().split()) if A == C == 1: print(-1) continue if B <= 2: max_cost = float('inf') else: max_cost = 0 if A >= B: max_cost += A - (B - 1) if C >= B: max_cost += C - (B - 1) if A == C: max_cost += 1 if A == 1 or C == 1 or A == C == 2: min_cost = float('inf') else: min_cost = 0 if A == C: min_cost += 1 C -= 1 min_cost += max(B - (min(A,C) - 1),0) ans = min(max_cost, min_cost) if ans == float('inf'): print(-1) else: print(ans) if __name__ == "__main__": main()