結果

問題 No.180 美しいWhitespace (2)
ユーザー lam6er
提出日時 2025-04-15 23:56:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 629 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 75,468 KB
最終ジャッジ日時 2025-04-15 23:58:15
合計ジャッジ時間 3,121 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
lines = []
for _ in range(n):
    a, b = map(int, input().split())
    lines.append((a, b))

def compute_f(x):
    if x <= 0:
        return float('inf')
    max_val = -float('inf')
    min_val = float('inf')
    for a, b in lines:
        val = a + b * x
        if val > max_val:
            max_val = val
        if val < min_val:
            min_val = val
    return max_val - min_val

low = 1
high = 10**18

while low < high:
    mid = (low + high) // 2
    current = compute_f(mid)
    next_val = compute_f(mid + 1)
    if current <= next_val:
        high = mid
    else:
        low = mid + 1

print(low)
0