結果

問題 No.966 引き算をして門松列(その1)
ユーザー tonnnura172tonnnura172
提出日時 2020-03-29 22:22:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,361 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 10,036 KB
最終ジャッジ日時 2023-08-30 20:01:13
合計ジャッジ時間 1,127 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

T = INT()

for _ in range(T):
	A, B, C = MAP()
	A2, B2, C2 = A, B, C
	ans1 = 0
	if A2 == C2:
		A2 -= 1
		ans1 += 1
	if A2 >= B2:
		ans1 += A2-(B2-1)
		A2 = B-1
	if C2 >= B2:
		ans1 += C2-(B2-1)
		C2 = B-1
	if A2 == C2:
		A2 -= 1
		ans1 += 1
	if 1 <= A2 and 1 <= B2 and 1 <= C2:
		ans1 = ans1
	else:
		ans1 = INF

	A2, B2, C2 = A, B, C
	ans2 = 0
	if A2 == C2:
		A2 -= 1
		ans2 += 1
	if B2 >= min(A2, C2):
		ans2 += B2-(min(A2, C2)-1)
		B2 = min(A2, C2)-1
	if 1 <= A2 and 1 <= B2 and 1 <= C2:
		ans2 = ans2
	else:
		ans2 = INF
	if ans1 == INF and ans2 == INF:
		print(-1)
	else:
		print(min(ans1, ans2))
0