結果

問題 No.180 美しいWhitespace (2)
ユーザー titiatitia
提出日時 2022-05-08 01:22:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 8,368 KB
最終ジャッジ日時 2023-09-21 13:35:58
合計ジャッジ時間 5,159 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,828 KB
testcase_01 AC 15 ms
7,856 KB
testcase_02 AC 16 ms
7,752 KB
testcase_03 AC 16 ms
7,852 KB
testcase_04 AC 26 ms
7,820 KB
testcase_05 AC 38 ms
7,864 KB
testcase_06 AC 49 ms
7,932 KB
testcase_07 AC 61 ms
7,908 KB
testcase_08 AC 73 ms
7,808 KB
testcase_09 AC 133 ms
8,368 KB
testcase_10 AC 134 ms
8,268 KB
testcase_11 AC 134 ms
8,248 KB
testcase_12 AC 136 ms
8,316 KB
testcase_13 AC 135 ms
8,316 KB
testcase_14 AC 135 ms
8,252 KB
testcase_15 AC 136 ms
8,296 KB
testcase_16 AC 136 ms
8,244 KB
testcase_17 AC 137 ms
8,248 KB
testcase_18 AC 137 ms
8,312 KB
testcase_19 AC 134 ms
8,364 KB
testcase_20 AC 16 ms
7,700 KB
testcase_21 AC 15 ms
7,828 KB
testcase_22 AC 15 ms
7,776 KB
testcase_23 AC 15 ms
7,888 KB
testcase_24 AC 14 ms
7,936 KB
testcase_25 AC 15 ms
7,848 KB
testcase_26 AC 15 ms
7,812 KB
testcase_27 AC 15 ms
7,764 KB
testcase_28 AC 15 ms
7,816 KB
testcase_29 AC 15 ms
7,812 KB
testcase_30 AC 127 ms
8,260 KB
testcase_31 AC 128 ms
8,248 KB
testcase_32 AC 130 ms
8,140 KB
testcase_33 AC 136 ms
8,308 KB
testcase_34 AC 137 ms
8,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
AB=[tuple(map(int,input().split())) for i in range(N)]

def calc(x):
    MIN=1<<64
    MAX=-1<<64

    for a,b in AB:
        MIN=min(a+x*b,MIN)
        MAX=max(a+x*b,MAX)

    return MAX-MIN

MIN=1
MAX=10**18

while MAX>MIN+10:
    x=MIN+(MAX-MIN)//3
    y=MIN+(MAX-MIN)//3*2

    if calc(x)>calc(y):
        MIN=x
    else:
        MAX=y
        

SCORE=1<<64

for i in range(MIN,MAX+1):
    if calc(i)<SCORE:
        ANS=i
        SCORE=calc(i)

print(ANS)
0