結果
| 問題 |
No.2420 Simple Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-13 09:21:48 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,034 bytes |
| コンパイル時間 | 164 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 59,208 KB |
| 最終ジャッジ日時 | 2024-11-21 03:05:59 |
| 合計ジャッジ時間 | 91,601 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 TLE * 29 |
ソースコード
import sys
import logging
import math
input = sys.stdin.readline
logger = logging.getLogger(__name__)
def read():
N = int(input().strip())
AB = []
for i in range(N):
a, b = map(int, input().strip().split())
AB.append((a, b))
return N, AB
def judge(x, a, b):
if (x * x - a - b) < 0:
return False
left = a * b * 4
right = (x * x - a - b) * (x * x - a - b)
return left < right
def solve(N, AB):
for a, b in AB:
ok = 10**11
ng = 2
while abs(ok - ng) > 1:
x = (ok + ng) // 2
if judge(x, a, b):
ok = x
else:
ng = x
ans = 0
for x in (ok-1, ok, ok+1):
if judge(x, a, b):
ans = x
break
if ans == 0:
raise RuntimeError
else:
print(ans)
if __name__ == "__main__":
inputs = read()
outputs = solve(*inputs)
if outputs is not None:
print("%s" % str(outputs))