結果

問題 No.1012 荷物収集
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-03-20 21:50:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 443 ms / 2,000 ms
コード長 650 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 120,860 KB
最終ジャッジ日時 2024-05-08 21:44:42
合計ジャッジ時間 12,128 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,968 KB
testcase_01 AC 36 ms
51,968 KB
testcase_02 AC 35 ms
51,712 KB
testcase_03 AC 34 ms
51,968 KB
testcase_04 AC 224 ms
120,348 KB
testcase_05 AC 228 ms
120,484 KB
testcase_06 AC 229 ms
120,476 KB
testcase_07 AC 221 ms
120,348 KB
testcase_08 AC 226 ms
120,860 KB
testcase_09 AC 230 ms
120,732 KB
testcase_10 AC 222 ms
120,488 KB
testcase_11 AC 223 ms
120,356 KB
testcase_12 AC 228 ms
120,608 KB
testcase_13 AC 231 ms
120,484 KB
testcase_14 AC 42 ms
53,760 KB
testcase_15 AC 54 ms
63,488 KB
testcase_16 AC 44 ms
54,016 KB
testcase_17 AC 54 ms
62,976 KB
testcase_18 AC 47 ms
59,776 KB
testcase_19 AC 41 ms
53,376 KB
testcase_20 AC 41 ms
53,888 KB
testcase_21 AC 45 ms
54,144 KB
testcase_22 AC 43 ms
54,144 KB
testcase_23 AC 42 ms
53,504 KB
testcase_24 AC 317 ms
102,272 KB
testcase_25 AC 384 ms
108,336 KB
testcase_26 AC 232 ms
88,244 KB
testcase_27 AC 116 ms
78,080 KB
testcase_28 AC 386 ms
101,492 KB
testcase_29 AC 264 ms
89,216 KB
testcase_30 AC 405 ms
112,412 KB
testcase_31 AC 193 ms
96,004 KB
testcase_32 AC 175 ms
89,216 KB
testcase_33 AC 235 ms
100,224 KB
testcase_34 AC 241 ms
103,808 KB
testcase_35 AC 347 ms
106,936 KB
testcase_36 AC 229 ms
106,552 KB
testcase_37 AC 251 ms
89,140 KB
testcase_38 AC 319 ms
97,004 KB
testcase_39 AC 176 ms
85,376 KB
testcase_40 AC 185 ms
85,376 KB
testcase_41 AC 443 ms
119,628 KB
testcase_42 AC 225 ms
96,640 KB
testcase_43 AC 285 ms
102,404 KB
testcase_44 AC 36 ms
51,968 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