結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-30 11:21:16 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 2,000 ms |
| コード長 | 1,036 bytes |
| コンパイル時間 | 957 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-12-14 23:36:08 |
| 合計ジャッジ時間 | 1,679 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
T = int(input())
ans_list = []
for i in range(T):
ans = 0
A, B, C = list(map(int, input().split()))
if A == C:
if A == 1:
ans_list.append(-1)
continue
else:
ans += 1
A -= 1
if A <= B <= C:
ba = B - A + 1
cb = C - B + 1
if C - cb == A:
cb += 1
if B <= ba and C <= cb:
ans_list.append(-1)
elif B <= ba:
ans_list.append(ans + cb)
elif C <= cb:
ans_list.append(ans + ba)
else:
ans_list.append(ans + min([ba, cb]))
elif C <= B <= A:
bc = B - C + 1
ab = A - B + 1
if A - ab == C:
ab += 1
if B <= bc and A <= ab:
ans_list.append(-1)
elif B <= bc:
ans_list.append(ans + ab)
elif A <= ab:
ans_list.append(ans + bc)
else:
ans_list.append(ans + min([bc, ab]))
else:
ans_list.append(ans)
for i in ans_list:
print(i)