結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,024 KB
testcase_01 AC 18 ms
7,984 KB
testcase_02 AC 16 ms
8,068 KB
testcase_03 AC 17 ms
7,972 KB
testcase_04 AC 28 ms
8,008 KB
testcase_05 WA -
testcase_06 AC 52 ms
8,020 KB
testcase_07 AC 63 ms
8,068 KB
testcase_08 AC 75 ms
8,052 KB
testcase_09 AC 134 ms
8,604 KB
testcase_10 AC 134 ms
8,492 KB
testcase_11 AC 135 ms
7,968 KB
testcase_12 AC 134 ms
8,468 KB
testcase_13 AC 134 ms
7,968 KB
testcase_14 AC 133 ms
8,432 KB
testcase_15 AC 134 ms
8,596 KB
testcase_16 AC 134 ms
8,512 KB
testcase_17 AC 134 ms
8,020 KB
testcase_18 AC 133 ms
8,488 KB
testcase_19 AC 134 ms
8,576 KB
testcase_20 AC 17 ms
7,960 KB
testcase_21 WA -
testcase_22 AC 17 ms
8,088 KB
testcase_23 AC 16 ms
8,156 KB
testcase_24 AC 16 ms
7,972 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 15 ms
8,116 KB
testcase_28 WA -
testcase_29 AC 16 ms
8,072 KB
testcase_30 AC 129 ms
7,964 KB
testcase_31 AC 131 ms
8,488 KB
testcase_32 AC 135 ms
8,652 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(right)) < f(floor(right)):
    print(int(ceil(right)))
else:
    print(int(floor(right)))
0