結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
tails1434
|
| 提出日時 | 2020-01-14 21:21:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 185 ms / 2,000 ms |
| コード長 | 1,115 bytes |
| コンパイル時間 | 358 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 76,928 KB |
| 最終ジャッジ日時 | 2024-12-26 11:03:00 |
| 合計ジャッジ時間 | 1,813 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
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
a = int(A)
b = int(B)
c = int(C)
if a >= b:
max_cost += a - (b - 1)
a = b - 1
if c >= b:
max_cost += c - (b - 1)
c = b - 1
if a == c:
max_cost += 1
if A == 1 or C == 1 or A == C == 2:
min_cost = float('inf')
else:
a = int(A)
b = int(B)
c = int(C)
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()
tails1434