結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-13 21:02:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 807 bytes |
| コンパイル時間 | 193 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-12-22 20:42:33 |
| 合計ジャッジ時間 | 7,573 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 TLE * 2 |
ソースコード
#!/usr/bin/env python3
import math
def iterate(a, b, c):
for a in range(a - 3, a + 1):
for b in range(b - 3, b + 1):
for c in range(c - 3, c + 1):
yield a, b, c
yield min(b - 1, a), b, min(b - 2, c)
yield min(b - 2, a), b, min(b - 1, c)
yield a, min(a - 1, b), c
yield a, min(c - 1, b), c
def solve(a, b, c):
ans = math.inf
for a1, b1, c1 in iterate(a, b, c):
if 1 <= a1 and 1 <= b1 and 1 <= c1:
if a1 != c1 and ((a1 < b1 and b1 > c1) or (a1 > b1 and b1 < c1)):
ans = min(ans, a - a1 + b - b1 + c - c1)
if math.isinf(ans):
return -1
return ans
for _ in range(int(input())):
a, b, c = map(int, input().split())
print(solve(a, b, c))