結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,076 KB
testcase_01 AC 16 ms
8,008 KB
testcase_02 AC 16 ms
8,056 KB
testcase_03 AC 17 ms
7,972 KB
testcase_04 AC 27 ms
7,948 KB
testcase_05 WA -
testcase_06 AC 51 ms
8,008 KB
testcase_07 AC 63 ms
8,112 KB
testcase_08 AC 77 ms
7,972 KB
testcase_09 AC 136 ms
8,488 KB
testcase_10 AC 133 ms
8,532 KB
testcase_11 AC 134 ms
7,972 KB
testcase_12 AC 133 ms
8,436 KB
testcase_13 AC 133 ms
8,008 KB
testcase_14 AC 135 ms
8,484 KB
testcase_15 AC 134 ms
8,436 KB
testcase_16 AC 133 ms
8,580 KB
testcase_17 AC 133 ms
8,656 KB
testcase_18 AC 134 ms
8,612 KB
testcase_19 AC 133 ms
8,532 KB
testcase_20 AC 16 ms
8,016 KB
testcase_21 WA -
testcase_22 AC 17 ms
8,016 KB
testcase_23 AC 16 ms
7,972 KB
testcase_24 AC 16 ms
8,048 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 16 ms
8,064 KB
testcase_28 WA -
testcase_29 AC 17 ms
8,008 KB
testcase_30 AC 130 ms
8,056 KB
testcase_31 AC 130 ms
8,492 KB
testcase_32 AC 134 ms
8,532 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
for i in range(100):
    y1 = f((left * 2 + right)/3)
    y2 = f((left+ right * 2)/3)

    if y1 <= y2:
        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