結果

問題 No.180 美しいWhitespace (2)
ユーザー e-mone-mon
提出日時 2015-10-28 16:55:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 8,676 KB
最終ジャッジ日時 2023-10-11 04:50:27
合計ジャッジ時間 5,310 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,364 KB
testcase_01 WA -
testcase_02 AC 17 ms
8,196 KB
testcase_03 AC 18 ms
8,432 KB
testcase_04 AC 34 ms
8,340 KB
testcase_05 AC 50 ms
8,472 KB
testcase_06 AC 67 ms
8,468 KB
testcase_07 AC 83 ms
8,360 KB
testcase_08 AC 100 ms
8,420 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 184 ms
8,612 KB
testcase_12 AC 186 ms
8,676 KB
testcase_13 AC 185 ms
8,532 KB
testcase_14 AC 185 ms
8,528 KB
testcase_15 AC 185 ms
8,480 KB
testcase_16 AC 185 ms
8,528 KB
testcase_17 AC 187 ms
8,488 KB
testcase_18 AC 185 ms
8,660 KB
testcase_19 AC 182 ms
8,552 KB
testcase_20 WA -
testcase_21 AC 17 ms
8,468 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 18 ms
8,272 KB
testcase_28 WA -
testcase_29 AC 17 ms
8,288 KB
testcase_30 AC 178 ms
8,556 KB
testcase_31 AC 181 ms
8,636 KB
testcase_32 WA -
testcase_33 AC 205 ms
7,976 KB
testcase_34 AC 192 ms
8,644 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 = 0
min_f = 10**20
for i in range(c - 30, min(c + 31, 10**9 + 1)):
    if f(i) < min_f:
        ans = i
        min_f = f(i)
print(ans)
0