結果

問題 No.180 美しいWhitespace (2)
ユーザー しらっ亭しらっ亭
提出日時 2015-07-29 02:03:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 8,424 KB
最終ジャッジ日時 2023-09-24 21:00:44
合計ジャッジ時間 3,098 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,852 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 16 ms
7,792 KB
testcase_04 AC 18 ms
7,800 KB
testcase_05 WA -
testcase_06 AC 22 ms
7,912 KB
testcase_07 AC 23 ms
7,940 KB
testcase_08 AC 25 ms
7,792 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 33 ms
8,340 KB
testcase_13 AC 33 ms
8,288 KB
testcase_14 AC 34 ms
8,288 KB
testcase_15 AC 33 ms
8,204 KB
testcase_16 AC 33 ms
8,228 KB
testcase_17 AC 33 ms
8,232 KB
testcase_18 AC 33 ms
8,412 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 16 ms
7,852 KB
testcase_22 WA -
testcase_23 AC 16 ms
7,848 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 35 ms
7,848 KB
testcase_30 AC 65 ms
8,340 KB
testcase_31 AC 67 ms
8,232 KB
testcase_32 WA -
testcase_33 AC 33 ms
8,296 KB
testcase_34 AC 33 ms
8,252 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)]
        return max(ls) - min(ls)

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

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

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

    print((a + b) // 2)


def main():
    solve()


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