結果
問題 | No.966 引き算をして門松列(その1) |
ユーザー | tails1434 |
提出日時 | 2020-01-14 21:18:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 655 ms |
コンパイル使用メモリ | 86,972 KB |
実行使用メモリ | 78,976 KB |
最終ジャッジ日時 | 2023-08-27 03:31:23 |
合計ジャッジ時間 | 1,879 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,352 KB |
testcase_01 | AC | 73 ms
71,332 KB |
testcase_02 | AC | 72 ms
71,036 KB |
testcase_03 | AC | 73 ms
71,264 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 157 ms
77,952 KB |
ソースコード
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()