結果

問題 No.1012 荷物収集
ユーザー stngstng
提出日時 2022-08-17 22:52:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 725 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 106,200 KB
最終ジャッジ日時 2024-04-15 10:34:12
合計ジャッジ時間 13,595 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 43 ms
52,480 KB
testcase_02 AC 42 ms
52,396 KB
testcase_03 AC 40 ms
52,224 KB
testcase_04 AC 274 ms
103,612 KB
testcase_05 AC 275 ms
103,880 KB
testcase_06 AC 272 ms
103,756 KB
testcase_07 AC 273 ms
103,488 KB
testcase_08 AC 271 ms
103,364 KB
testcase_09 AC 273 ms
103,624 KB
testcase_10 AC 276 ms
103,356 KB
testcase_11 AC 274 ms
103,240 KB
testcase_12 AC 268 ms
103,624 KB
testcase_13 AC 275 ms
103,368 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 39 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
n,q = map(int,input().split())
xw = [[int(i) for i in input().split()] for j in range(n)]
x = [int(i) for i in input().split()]

x.sort()
xw.sort()
pos = []
wei = []
for i in range(n):
    pos.append(xw[i][0])
    wei.append(xw[i][1])

rw = [0]*(n+1)
for i in range(n):
    rw[i+1] = rw[i]+wei[i]

ans = 0
for i in range(n):
    ans += abs(x[0]-pos[i])*wei[i]

print(ans)

for i in range(q-1):
    bidx = bisect.bisect_right(pos,x[i])
    aidx = bisect.bisect_left(pos,x[i+1])
    #print(bidx,aidx,rw)
    ans += (x[i+1]-x[i])*(rw[bidx]-rw[0])
    ans -= (x[i+1]-x[i])*(rw[n]-rw[aidx])
    for j in range(bidx,aidx):
        ans -= abs(x[i]-pos[j])*wei[j]
        ans += abs(x[i+1]-pos[j])*wei[j]
    print(ans)
0