結果

問題 No.1012 荷物収集
ユーザー kohei2019kohei2019
提出日時 2022-07-12 00:02:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 104,304 KB
最終ジャッジ日時 2023-09-04 22:06:20
合計ジャッジ時間 18,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,256 KB
testcase_01 AC 73 ms
71,236 KB
testcase_02 AC 74 ms
71,288 KB
testcase_03 AC 75 ms
71,148 KB
testcase_04 AC 235 ms
104,064 KB
testcase_05 AC 239 ms
104,008 KB
testcase_06 AC 235 ms
104,304 KB
testcase_07 AC 234 ms
104,004 KB
testcase_08 AC 233 ms
103,860 KB
testcase_09 AC 233 ms
104,156 KB
testcase_10 AC 234 ms
104,148 KB
testcase_11 AC 234 ms
104,176 KB
testcase_12 AC 233 ms
103,904 KB
testcase_13 AC 234 ms
103,984 KB
testcase_14 AC 79 ms
71,140 KB
testcase_15 AC 84 ms
75,432 KB
testcase_16 AC 79 ms
71,292 KB
testcase_17 AC 81 ms
75,232 KB
testcase_18 AC 79 ms
75,152 KB
testcase_19 AC 74 ms
71,356 KB
testcase_20 AC 76 ms
71,248 KB
testcase_21 AC 77 ms
71,136 KB
testcase_22 AC 77 ms
71,300 KB
testcase_23 AC 81 ms
71,148 KB
testcase_24 AC 436 ms
95,244 KB
testcase_25 AC 548 ms
103,196 KB
testcase_26 AC 338 ms
82,912 KB
testcase_27 AC 166 ms
78,604 KB
testcase_28 AC 542 ms
97,744 KB
testcase_29 AC 378 ms
83,248 KB
testcase_30 AC 542 ms
98,184 KB
testcase_31 AC 273 ms
92,532 KB
testcase_32 AC 251 ms
84,348 KB
testcase_33 AC 327 ms
93,196 KB
testcase_34 AC 350 ms
95,672 KB
testcase_35 AC 468 ms
90,004 KB
testcase_36 AC 327 ms
97,388 KB
testcase_37 AC 369 ms
82,920 KB
testcase_38 AC 451 ms
95,296 KB
testcase_39 AC 256 ms
82,340 KB
testcase_40 AC 284 ms
86,124 KB
testcase_41 AC 594 ms
95,328 KB
testcase_42 AC 328 ms
87,644 KB
testcase_43 AC 420 ms
90,512 KB
testcase_44 AC 71 ms
71,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = map(int,input().split())
lsxw = []
v = 0
rw = 0
for i in range(N):
    x,w = map(int,input().split())
    lsxw.append((x,w))
    v += x*w
    rw += w
lsxw.sort(reverse=True)
ll = list(map(int,input().split()))
lsX = []
for i in range(Q):
    X = ll[i]
    lsX.append((X,i))
lsX.sort()
lsans = [0]*Q
lw = 0
#print(v,rw,lw)
now = 0
for i in range(Q):
    xx,ind = lsX[i]
    while lsxw and lsxw[-1][0] <= xx:
        x,w = lsxw.pop()
        v -= rw*(x-now)
        v += lw*(x-now)
        now = x
        rw -= w
        lw += w
    v -= rw*(xx-now)
    v += lw*(xx-now)
    now = xx
    lsans[ind] = v
print(*lsans,sep='\n')


0