結果

問題 No.1012 荷物収集
ユーザー ayaoniayaoni
提出日時 2020-12-09 16:00:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 676 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 1,447 ms
コンパイル使用メモリ 80,704 KB
実行使用メモリ 120,784 KB
最終ジャッジ日時 2023-10-19 04:57:31
合計ジャッジ時間 17,546 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,372 KB
testcase_01 AC 39 ms
53,372 KB
testcase_02 AC 39 ms
53,372 KB
testcase_03 AC 39 ms
53,372 KB
testcase_04 AC 215 ms
119,872 KB
testcase_05 AC 279 ms
120,776 KB
testcase_06 AC 203 ms
120,784 KB
testcase_07 AC 201 ms
120,784 KB
testcase_08 AC 202 ms
120,784 KB
testcase_09 AC 210 ms
120,784 KB
testcase_10 AC 200 ms
120,784 KB
testcase_11 AC 200 ms
120,784 KB
testcase_12 AC 202 ms
120,784 KB
testcase_13 AC 201 ms
120,784 KB
testcase_14 AC 45 ms
53,344 KB
testcase_15 AC 50 ms
61,572 KB
testcase_16 AC 42 ms
53,344 KB
testcase_17 AC 49 ms
61,572 KB
testcase_18 AC 47 ms
58,796 KB
testcase_19 AC 41 ms
53,344 KB
testcase_20 AC 42 ms
53,344 KB
testcase_21 AC 41 ms
53,344 KB
testcase_22 AC 42 ms
55,392 KB
testcase_23 AC 40 ms
53,344 KB
testcase_24 AC 461 ms
107,988 KB
testcase_25 AC 598 ms
102,768 KB
testcase_26 AC 322 ms
86,488 KB
testcase_27 AC 116 ms
77,912 KB
testcase_28 AC 601 ms
110,440 KB
testcase_29 AC 362 ms
88,236 KB
testcase_30 AC 620 ms
111,544 KB
testcase_31 AC 244 ms
90,576 KB
testcase_32 AC 208 ms
85,192 KB
testcase_33 AC 321 ms
102,408 KB
testcase_34 AC 347 ms
108,236 KB
testcase_35 AC 511 ms
100,216 KB
testcase_36 AC 313 ms
94,616 KB
testcase_37 AC 363 ms
88,316 KB
testcase_38 AC 479 ms
107,176 KB
testcase_39 AC 238 ms
87,476 KB
testcase_40 AC 269 ms
92,412 KB
testcase_41 AC 676 ms
117,936 KB
testcase_42 AC 412 ms
95,768 KB
testcase_43 AC 439 ms
101,392 KB
testcase_44 AC 39 ms
53,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,Q = MI()

X = []
a,b = 0,0
c,d = 0,0
for _ in range(N):
    x,w = MI()
    X.append((x,w,0))
    b += w
    d += x*w

Y = LI()
for i in range(Q):
    X.append((Y[i],0,i))

X.sort()

ANS = [0]*Q
for x,w,i in X:
    if w == 0:
        ANS[i] = x*(a-b)-(c-d)
    else:
        a += w
        b -= w
        c += x*w
        d -= x*w

print(*ANS,sep='\n')
0