結果

問題 No.1012 荷物収集
ユーザー qibqib
提出日時 2022-10-27 19:22:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 417 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 86,072 KB
実行使用メモリ 109,160 KB
最終ジャッジ日時 2023-09-18 13:54:30
合計ジャッジ時間 13,851 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,124 KB
testcase_01 AC 80 ms
71,224 KB
testcase_02 AC 82 ms
71,260 KB
testcase_03 AC 83 ms
71,224 KB
testcase_04 AC 282 ms
104,816 KB
testcase_05 AC 280 ms
104,764 KB
testcase_06 AC 282 ms
105,128 KB
testcase_07 AC 281 ms
104,996 KB
testcase_08 AC 278 ms
105,056 KB
testcase_09 AC 282 ms
104,808 KB
testcase_10 AC 281 ms
105,060 KB
testcase_11 AC 281 ms
104,768 KB
testcase_12 AC 284 ms
104,756 KB
testcase_13 AC 280 ms
104,988 KB
testcase_14 AC 86 ms
75,092 KB
testcase_15 AC 96 ms
76,308 KB
testcase_16 AC 91 ms
75,208 KB
testcase_17 AC 95 ms
76,324 KB
testcase_18 AC 96 ms
76,492 KB
testcase_19 AC 84 ms
75,048 KB
testcase_20 AC 82 ms
71,336 KB
testcase_21 AC 90 ms
75,156 KB
testcase_22 AC 88 ms
75,292 KB
testcase_23 AC 86 ms
75,196 KB
testcase_24 AC 310 ms
100,840 KB
testcase_25 AC 380 ms
101,580 KB
testcase_26 AC 303 ms
95,136 KB
testcase_27 AC 176 ms
81,836 KB
testcase_28 AC 392 ms
107,424 KB
testcase_29 AC 346 ms
98,312 KB
testcase_30 AC 410 ms
101,288 KB
testcase_31 AC 184 ms
88,488 KB
testcase_32 AC 212 ms
86,412 KB
testcase_33 AC 233 ms
91,408 KB
testcase_34 AC 227 ms
90,704 KB
testcase_35 AC 355 ms
97,108 KB
testcase_36 AC 204 ms
91,728 KB
testcase_37 AC 331 ms
97,680 KB
testcase_38 AC 328 ms
99,064 KB
testcase_39 AC 235 ms
87,788 KB
testcase_40 AC 232 ms
86,888 KB
testcase_41 AC 417 ms
109,160 KB
testcase_42 AC 254 ms
92,864 KB
testcase_43 AC 311 ms
92,888 KB
testcase_44 AC 77 ms
71,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1 << 30

import bisect as bs

n, q = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(n)]
items.append([- INF, 0])
items.append([INF, 0])

items.sort(key=lambda x: x[0])
xs = [items[i][0] for i in range(len(items))]

xws = [0 for _ in range(n + 2)]
ws = [0 for _ in range(n + 2)]
for i in range(1, n + 2):
	xi, wi = items[i]
	xws[i] = xws[i - 1] + xi * wi
	ws[i] = ws[i - 1] + wi

queries = list(map(int, input().split()))
for i in range(q):
	k = bs.bisect_right(xs, queries[i])
	print(xws[n] - 2 * xws[k - 1] + queries[i] * (2 * ws[k - 1] - ws[n]))
0