結果

問題 No.1012 荷物収集
ユーザー qqqqqqqq
提出日時 2020-03-26 17:51:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 518 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 121,408 KB
最終ジャッジ日時 2023-08-30 13:12:41
合計ジャッジ時間 16,626 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,092 KB
testcase_01 AC 72 ms
71,152 KB
testcase_02 AC 71 ms
71,024 KB
testcase_03 AC 72 ms
71,296 KB
testcase_04 AC 241 ms
120,776 KB
testcase_05 AC 236 ms
121,232 KB
testcase_06 AC 234 ms
121,228 KB
testcase_07 AC 235 ms
121,240 KB
testcase_08 AC 241 ms
121,372 KB
testcase_09 AC 241 ms
121,228 KB
testcase_10 AC 237 ms
121,236 KB
testcase_11 AC 239 ms
121,136 KB
testcase_12 AC 232 ms
121,240 KB
testcase_13 AC 236 ms
121,408 KB
testcase_14 AC 79 ms
75,100 KB
testcase_15 AC 86 ms
75,812 KB
testcase_16 AC 82 ms
75,332 KB
testcase_17 AC 83 ms
75,836 KB
testcase_18 AC 84 ms
75,660 KB
testcase_19 AC 78 ms
75,020 KB
testcase_20 AC 76 ms
71,172 KB
testcase_21 AC 82 ms
75,128 KB
testcase_22 AC 81 ms
75,640 KB
testcase_23 AC 81 ms
75,276 KB
testcase_24 AC 329 ms
103,568 KB
testcase_25 AC 439 ms
105,148 KB
testcase_26 AC 361 ms
99,388 KB
testcase_27 AC 158 ms
81,596 KB
testcase_28 AC 475 ms
112,844 KB
testcase_29 AC 455 ms
108,420 KB
testcase_30 AC 518 ms
118,292 KB
testcase_31 AC 158 ms
86,936 KB
testcase_32 AC 195 ms
86,128 KB
testcase_33 AC 211 ms
90,852 KB
testcase_34 AC 196 ms
90,792 KB
testcase_35 AC 425 ms
108,956 KB
testcase_36 AC 172 ms
90,752 KB
testcase_37 AC 406 ms
102,072 KB
testcase_38 AC 345 ms
105,384 KB
testcase_39 AC 229 ms
87,668 KB
testcase_40 AC 228 ms
89,360 KB
testcase_41 AC 497 ms
121,200 KB
testcase_42 AC 248 ms
92,884 KB
testcase_43 AC 356 ms
105,248 KB
testcase_44 AC 71 ms
71,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

n,q = map(int, input().split())
x_set = set()
xw = []
for i in range(n):
    x,w = map(int, input().split())
    x_set.add(x)
    xw.append([x,w])
xw.sort()
dd = sorted(x_set)

xs = list(map(int, input().split()))

w_sum = [0]
xw_sum = [0]
for x,w in xw:
    w_sum.append(w_sum[-1] + w)
    xw_sum.append(xw_sum[-1] + x*w)

from bisect import bisect_left
ans = []
for xi in xs:
    j = bisect_left(dd, xi)
    cost = w_sum[j]*xi - xw_sum[j]
    cost += (xw_sum[-1]-xw_sum[j]) - (w_sum[-1]-w_sum[j])*xi
    ans.append(cost)
print(*ans, sep="\n")
0