結果

問題 No.180 美しいWhitespace (2)
ユーザー e-mone-mon
提出日時 2015-10-30 18:33:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 202 ms / 5,000 ms
コード長 792 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 8,652 KB
最終ジャッジ日時 2023-10-11 06:03:43
合計ジャッジ時間 5,090 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,412 KB
testcase_01 AC 18 ms
8,316 KB
testcase_02 AC 18 ms
8,336 KB
testcase_03 AC 19 ms
8,324 KB
testcase_04 AC 35 ms
8,368 KB
testcase_05 AC 52 ms
8,228 KB
testcase_06 AC 70 ms
8,420 KB
testcase_07 AC 89 ms
8,292 KB
testcase_08 AC 107 ms
8,284 KB
testcase_09 AC 164 ms
8,620 KB
testcase_10 AC 162 ms
8,652 KB
testcase_11 AC 196 ms
8,440 KB
testcase_12 AC 196 ms
7,992 KB
testcase_13 AC 195 ms
8,564 KB
testcase_14 AC 196 ms
8,624 KB
testcase_15 AC 195 ms
8,600 KB
testcase_16 AC 195 ms
8,620 KB
testcase_17 AC 196 ms
8,544 KB
testcase_18 AC 171 ms
8,592 KB
testcase_19 AC 163 ms
8,404 KB
testcase_20 AC 17 ms
8,408 KB
testcase_21 AC 17 ms
8,452 KB
testcase_22 AC 17 ms
8,260 KB
testcase_23 AC 17 ms
8,412 KB
testcase_24 AC 17 ms
8,264 KB
testcase_25 AC 17 ms
8,428 KB
testcase_26 AC 17 ms
8,040 KB
testcase_27 AC 17 ms
8,196 KB
testcase_28 AC 17 ms
8,400 KB
testcase_29 AC 17 ms
8,256 KB
testcase_30 AC 187 ms
8,404 KB
testcase_31 AC 191 ms
8,436 KB
testcase_32 AC 162 ms
8,548 KB
testcase_33 AC 202 ms
8,456 KB
testcase_34 AC 201 ms
8,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from math import ceil
from math import floor

def f(x):
    max_f = -1
    min_f = 10**20
    for a,b in AB:
        max_f = max(max_f, a + b * x)
        min_f = min(min_f, a + b * x)
    return max_f - min_f


N = int(input())
AB = [list(map(int,input().split())) for i in range(0,N)]

left = 1
right = 10**10
eps = 1e-6

for i in range(100):
    y1 = f((left * 2 + right)/3)
    y2 = f((left+ right * 2)/3)

    if y1 <= y2 + eps:
        right = (left + right * 2)/3
    else:
        left = (left * 2 + right)/3

if f(ceil(left)) < f(floor(left)):
    c = ceil(left)
else:
    c = floor(left)

ans = 1
min_f = 10**20
for i in range(max(1,c - 30), min(c + 50, 10**9 + 1)):
    if f(i) < min_f:
        ans = i
        min_f = f(i)
print(ans)
0