結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,936 KB
testcase_01 AC 18 ms
8,116 KB
testcase_02 AC 17 ms
7,960 KB
testcase_03 AC 18 ms
8,076 KB
testcase_04 AC 28 ms
7,936 KB
testcase_05 AC 40 ms
7,936 KB
testcase_06 AC 52 ms
8,012 KB
testcase_07 AC 63 ms
8,048 KB
testcase_08 AC 76 ms
7,968 KB
testcase_09 AC 137 ms
8,680 KB
testcase_10 AC 135 ms
8,464 KB
testcase_11 AC 135 ms
8,476 KB
testcase_12 AC 135 ms
8,488 KB
testcase_13 AC 138 ms
8,520 KB
testcase_14 AC 134 ms
8,596 KB
testcase_15 AC 138 ms
8,532 KB
testcase_16 AC 134 ms
8,456 KB
testcase_17 AC 134 ms
8,464 KB
testcase_18 AC 134 ms
8,604 KB
testcase_19 AC 136 ms
8,608 KB
testcase_20 AC 16 ms
8,016 KB
testcase_21 WA -
testcase_22 AC 16 ms
8,004 KB
testcase_23 AC 16 ms
7,940 KB
testcase_24 AC 16 ms
8,008 KB
testcase_25 AC 16 ms
7,968 KB
testcase_26 AC 17 ms
8,008 KB
testcase_27 AC 17 ms
7,972 KB
testcase_28 WA -
testcase_29 AC 17 ms
8,108 KB
testcase_30 AC 132 ms
7,936 KB
testcase_31 AC 133 ms
8,532 KB
testcase_32 AC 134 ms
8,684 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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-7

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)):
    print(int(ceil(left)))
else:
    print(int(floor(left)))
0