結果

問題 No.180 美しいWhitespace (2)
ユーザー e-mone-mon
提出日時 2015-10-30 18:37:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 791 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 8,660 KB
最終ジャッジ日時 2023-10-11 06:05:12
合計ジャッジ時間 5,899 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,356 KB
testcase_01 AC 16 ms
8,368 KB
testcase_02 AC 16 ms
8,236 KB
testcase_03 AC 18 ms
8,404 KB
testcase_04 AC 34 ms
8,284 KB
testcase_05 AC 50 ms
8,384 KB
testcase_06 AC 67 ms
8,464 KB
testcase_07 AC 84 ms
8,288 KB
testcase_08 AC 101 ms
8,292 KB
testcase_09 AC 153 ms
8,436 KB
testcase_10 AC 151 ms
8,616 KB
testcase_11 AC 184 ms
8,468 KB
testcase_12 AC 186 ms
8,584 KB
testcase_13 AC 184 ms
8,452 KB
testcase_14 AC 185 ms
8,564 KB
testcase_15 AC 187 ms
8,460 KB
testcase_16 AC 187 ms
7,964 KB
testcase_17 AC 186 ms
8,496 KB
testcase_18 AC 160 ms
8,460 KB
testcase_19 AC 153 ms
8,496 KB
testcase_20 AC 17 ms
8,372 KB
testcase_21 WA -
testcase_22 AC 17 ms
8,440 KB
testcase_23 AC 17 ms
8,260 KB
testcase_24 AC 16 ms
8,384 KB
testcase_25 AC 17 ms
8,252 KB
testcase_26 AC 17 ms
8,388 KB
testcase_27 AC 17 ms
8,228 KB
testcase_28 AC 18 ms
8,372 KB
testcase_29 AC 18 ms
8,384 KB
testcase_30 AC 177 ms
8,648 KB
testcase_31 AC 181 ms
8,568 KB
testcase_32 AC 152 ms
8,452 KB
testcase_33 WA -
testcase_34 AC 190 ms
8,660 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**9
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 + 30, 10**9 + 1)):
    if f(i) < min_f:
        ans = i
        min_f = f(i)
print(ans)
0