結果

問題 No.1012 荷物収集
ユーザー ryusukeryusuke
提出日時 2022-02-20 18:46:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 424 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 115,380 KB
最終ジャッジ日時 2023-09-11 21:08:05
合計ジャッジ時間 15,433 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,176 KB
testcase_01 AC 79 ms
71,396 KB
testcase_02 AC 79 ms
71,164 KB
testcase_03 AC 79 ms
71,152 KB
testcase_04 AC 300 ms
115,132 KB
testcase_05 AC 253 ms
115,140 KB
testcase_06 AC 254 ms
115,240 KB
testcase_07 AC 255 ms
115,240 KB
testcase_08 AC 250 ms
115,264 KB
testcase_09 AC 256 ms
115,136 KB
testcase_10 AC 251 ms
115,140 KB
testcase_11 AC 252 ms
115,368 KB
testcase_12 AC 259 ms
115,184 KB
testcase_13 AC 260 ms
115,380 KB
testcase_14 AC 77 ms
75,308 KB
testcase_15 AC 87 ms
76,520 KB
testcase_16 AC 81 ms
75,260 KB
testcase_17 AC 84 ms
76,344 KB
testcase_18 AC 86 ms
76,424 KB
testcase_19 AC 77 ms
75,100 KB
testcase_20 AC 77 ms
71,420 KB
testcase_21 AC 81 ms
75,556 KB
testcase_22 AC 80 ms
75,448 KB
testcase_23 AC 79 ms
75,444 KB
testcase_24 AC 290 ms
93,320 KB
testcase_25 AC 368 ms
109,328 KB
testcase_26 AC 286 ms
94,748 KB
testcase_27 AC 163 ms
81,100 KB
testcase_28 AC 383 ms
102,328 KB
testcase_29 AC 322 ms
102,640 KB
testcase_30 AC 391 ms
111,168 KB
testcase_31 AC 172 ms
88,100 KB
testcase_32 AC 191 ms
85,224 KB
testcase_33 AC 215 ms
93,096 KB
testcase_34 AC 212 ms
90,188 KB
testcase_35 AC 331 ms
104,432 KB
testcase_36 AC 189 ms
91,716 KB
testcase_37 AC 308 ms
99,508 KB
testcase_38 AC 304 ms
101,780 KB
testcase_39 AC 209 ms
85,704 KB
testcase_40 AC 217 ms
86,364 KB
testcase_41 AC 424 ms
114,436 KB
testcase_42 AC 239 ms
93,540 KB
testcase_43 AC 307 ms
94,744 KB
testcase_44 AC 72 ms
71,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

n, q = map(int, input().split())
xw = [list(map(int, input().split())) for _ in range(n)]
x = list(map(int, input().split()))

xw.sort(key=lambda x: x[0])

sort_list = [xw[i][0] for i in range(n)]

accum_xw = [0]
accum_w = [0]
for i in range(n):
    accum_xw.append(accum_xw[-1] + xw[i][0] * xw[i][1])
    accum_w.append(accum_w[-1] + xw[i][1])

for i in range(q):
    t = bisect_left(sort_list, x[i])

    W = 2 * x[i] * accum_w[t]
    X = -2 * accum_xw[t]
    Y = accum_xw[-1]
    Z = -x[i] * accum_w[-1]
    ans = W + X + Y + Z
    print(ans)
0