結果

問題 No.1012 荷物収集
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-29 03:12:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 521 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 98,620 KB
最終ジャッジ日時 2024-04-15 02:37:15
合計ジャッジ時間 12,558 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,196 KB
testcase_01 AC 37 ms
53,136 KB
testcase_02 AC 36 ms
52,644 KB
testcase_03 AC 33 ms
52,940 KB
testcase_04 AC 151 ms
98,620 KB
testcase_05 AC 148 ms
98,348 KB
testcase_06 AC 148 ms
98,140 KB
testcase_07 AC 146 ms
98,144 KB
testcase_08 AC 150 ms
98,360 KB
testcase_09 AC 148 ms
98,336 KB
testcase_10 AC 148 ms
98,360 KB
testcase_11 AC 146 ms
98,356 KB
testcase_12 AC 145 ms
98,296 KB
testcase_13 AC 149 ms
98,520 KB
testcase_14 AC 37 ms
53,384 KB
testcase_15 AC 46 ms
62,600 KB
testcase_16 AC 41 ms
60,604 KB
testcase_17 AC 46 ms
64,516 KB
testcase_18 AC 43 ms
61,288 KB
testcase_19 AC 36 ms
53,272 KB
testcase_20 AC 36 ms
54,044 KB
testcase_21 AC 40 ms
61,236 KB
testcase_22 AC 41 ms
61,156 KB
testcase_23 AC 40 ms
59,396 KB
testcase_24 AC 360 ms
89,828 KB
testcase_25 AC 471 ms
94,728 KB
testcase_26 AC 264 ms
81,940 KB
testcase_27 AC 99 ms
77,172 KB
testcase_28 AC 455 ms
93,180 KB
testcase_29 AC 287 ms
82,292 KB
testcase_30 AC 471 ms
94,108 KB
testcase_31 AC 212 ms
86,880 KB
testcase_32 AC 184 ms
82,552 KB
testcase_33 AC 265 ms
88,480 KB
testcase_34 AC 279 ms
90,424 KB
testcase_35 AC 398 ms
90,552 KB
testcase_36 AC 261 ms
90,048 KB
testcase_37 AC 276 ms
82,548 KB
testcase_38 AC 377 ms
90,240 KB
testcase_39 AC 195 ms
82,164 KB
testcase_40 AC 224 ms
84,456 KB
testcase_41 AC 521 ms
95,852 KB
testcase_42 AC 262 ms
85,092 KB
testcase_43 AC 349 ms
87,700 KB
testcase_44 AC 34 ms
51,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
task = []
for _ in range(N):
    x, w = map(int, input().split())
    task.append((x, w))
for i, x in enumerate(map(int, input().split())):
    task.append((x, ~i))

task.sort()
ans = [0] * Q


def calc():
    weight = 0
    score = 0
    now = 0
    for x, i in task:
        d = abs(x - now)
        score += d * weight
        if i < 0:
            i = ~i
            ans[i] += score
        else:
            weight += i
        now = x


calc()
task.reverse()
calc()
print(*ans, sep="\n")
0