結果

問題 No.180 美しいWhitespace (2)
ユーザー しらっ亭しらっ亭
提出日時 2015-07-29 02:14:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-09-24 21:06:27
合計ジャッジ時間 2,414 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,732 KB
testcase_01 AC 18 ms
7,844 KB
testcase_02 AC 16 ms
7,892 KB
testcase_03 AC 17 ms
7,888 KB
testcase_04 AC 18 ms
7,816 KB
testcase_05 AC 20 ms
7,800 KB
testcase_06 AC 21 ms
7,816 KB
testcase_07 AC 23 ms
7,812 KB
testcase_08 AC 24 ms
7,784 KB
testcase_09 AC 35 ms
8,204 KB
testcase_10 AC 34 ms
8,268 KB
testcase_11 AC 34 ms
8,168 KB
testcase_12 AC 34 ms
8,308 KB
testcase_13 AC 35 ms
8,328 KB
testcase_14 AC 34 ms
8,292 KB
testcase_15 AC 34 ms
8,340 KB
testcase_16 AC 34 ms
8,168 KB
testcase_17 AC 34 ms
8,328 KB
testcase_18 AC 34 ms
8,268 KB
testcase_19 AC 33 ms
8,304 KB
testcase_20 AC 16 ms
7,828 KB
testcase_21 AC 16 ms
7,852 KB
testcase_22 AC 16 ms
7,732 KB
testcase_23 AC 16 ms
7,732 KB
testcase_24 AC 16 ms
7,736 KB
testcase_25 AC 17 ms
7,828 KB
testcase_26 AC 17 ms
7,728 KB
testcase_27 AC 16 ms
7,828 KB
testcase_28 AC 16 ms
7,824 KB
testcase_29 AC 16 ms
7,776 KB
testcase_30 AC 33 ms
8,164 KB
testcase_31 AC 34 ms
8,156 KB
testcase_32 AC 34 ms
8,340 KB
testcase_33 AC 34 ms
8,204 KB
testcase_34 AC 34 ms
8,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = list(map(int, input().split()))

    a = 1
    b = max(A) + 1

    def f(x):
        ls = [A[i] + B[i] * x for i in range(N)]
        #print(x, ls)
        return max(ls) - min(ls)

    for i in range(55):
        c1 = (a * 2 + b) // 3
        c2 = (a + b * 2) // 3

        fc1 = f(c1)
        fc2 = f(c2)

        #print((a, b), (c1, c2), (fc1, fc2))

        if fc1 <= fc2:
            b = c2
        else:
            a = c1

    print((a + b) // 2)


def main():
    solve()


if __name__ == '__main__':
    main()
0