結果

問題 No.1012 荷物収集
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-03-20 21:50:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 650 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 119,528 KB
最終ジャッジ日時 2023-08-21 16:14:33
合計ジャッジ時間 14,596 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,308 KB
testcase_01 AC 70 ms
71,428 KB
testcase_02 AC 70 ms
71,364 KB
testcase_03 AC 69 ms
71,468 KB
testcase_04 AC 286 ms
119,300 KB
testcase_05 AC 254 ms
119,340 KB
testcase_06 AC 253 ms
119,276 KB
testcase_07 AC 254 ms
119,184 KB
testcase_08 AC 255 ms
119,528 KB
testcase_09 AC 255 ms
119,244 KB
testcase_10 AC 257 ms
119,420 KB
testcase_11 AC 251 ms
119,256 KB
testcase_12 AC 251 ms
119,260 KB
testcase_13 AC 252 ms
119,380 KB
testcase_14 AC 75 ms
71,308 KB
testcase_15 AC 86 ms
76,484 KB
testcase_16 AC 76 ms
71,124 KB
testcase_17 AC 86 ms
76,412 KB
testcase_18 AC 80 ms
75,224 KB
testcase_19 AC 74 ms
71,332 KB
testcase_20 AC 76 ms
71,480 KB
testcase_21 AC 78 ms
71,372 KB
testcase_22 AC 77 ms
71,256 KB
testcase_23 AC 74 ms
71,184 KB
testcase_24 AC 357 ms
100,452 KB
testcase_25 AC 472 ms
106,460 KB
testcase_26 AC 286 ms
91,108 KB
testcase_27 AC 145 ms
79,068 KB
testcase_28 AC 441 ms
109,972 KB
testcase_29 AC 289 ms
89,776 KB
testcase_30 AC 460 ms
113,152 KB
testcase_31 AC 235 ms
100,744 KB
testcase_32 AC 199 ms
90,032 KB
testcase_33 AC 261 ms
98,888 KB
testcase_34 AC 280 ms
104,616 KB
testcase_35 AC 381 ms
105,928 KB
testcase_36 AC 269 ms
108,396 KB
testcase_37 AC 292 ms
89,568 KB
testcase_38 AC 387 ms
105,092 KB
testcase_39 AC 206 ms
86,356 KB
testcase_40 AC 244 ms
92,204 KB
testcase_41 AC 538 ms
118,868 KB
testcase_42 AC 281 ms
97,624 KB
testcase_43 AC 355 ms
102,376 KB
testcase_44 AC 70 ms
71,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, Qn = map(int, input().split()) 
X = []
for _ in range(N):
    x, w = map(int, input().split())
    X.append((x, w, 0))
Q = list(map(int, input().split()))
for i, x in enumerate(Q):
    X.append((x, i, 1))
X.sort(key=lambda x:x[0])

rs1 = [0] * Qn
wsum = bx = ss=0
for x, d, t in X:
    if t:
        ss += (x-bx)*wsum
        rs1[d] = ss
    else:
        ss += (x-bx)*wsum
        wsum += d
    bx = x


rs2 = [0] * Qn
wsum = bx = ss=0
for x, d, t in X[::-1]:
    if t:
        ss += -(x-bx)*wsum
        rs2[d] = ss
    else:
        ss += -(x-bx)*wsum
        wsum += d
    bx = x

#print(rs1, rs2)
for i in range(Qn):
    print(rs1[i]+rs2[i])
0