結果

問題 No.180 美しいWhitespace (2)
ユーザー e-mone-mon
提出日時 2015-10-30 18:31:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 8,640 KB
最終ジャッジ日時 2023-10-11 06:03:07
合計ジャッジ時間 5,296 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,308 KB
testcase_01 AC 16 ms
8,320 KB
testcase_02 AC 15 ms
8,396 KB
testcase_03 AC 18 ms
8,396 KB
testcase_04 AC 32 ms
8,280 KB
testcase_05 AC 49 ms
8,464 KB
testcase_06 AC 66 ms
8,312 KB
testcase_07 AC 83 ms
7,976 KB
testcase_08 AC 100 ms
8,476 KB
testcase_09 AC 150 ms
8,604 KB
testcase_10 AC 151 ms
8,532 KB
testcase_11 AC 185 ms
8,468 KB
testcase_12 AC 185 ms
8,632 KB
testcase_13 AC 182 ms
8,476 KB
testcase_14 AC 184 ms
8,620 KB
testcase_15 AC 184 ms
8,148 KB
testcase_16 AC 183 ms
8,488 KB
testcase_17 AC 184 ms
8,468 KB
testcase_18 AC 160 ms
8,632 KB
testcase_19 AC 151 ms
8,636 KB
testcase_20 AC 17 ms
8,336 KB
testcase_21 AC 17 ms
8,268 KB
testcase_22 AC 16 ms
8,424 KB
testcase_23 AC 16 ms
8,420 KB
testcase_24 AC 16 ms
8,368 KB
testcase_25 AC 17 ms
8,396 KB
testcase_26 AC 16 ms
8,120 KB
testcase_27 AC 17 ms
8,264 KB
testcase_28 WA -
testcase_29 AC 17 ms
8,372 KB
testcase_30 AC 177 ms
7,952 KB
testcase_31 AC 181 ms
8,640 KB
testcase_32 AC 152 ms
8,508 KB
testcase_33 AC 204 ms
8,592 KB
testcase_34 AC 192 ms
8,480 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 + 31, 10**9 + 1)):
    if f(i) < min_f:
        ans = i
        min_f = f(i)
print(ans)
0