結果

問題 No.1012 荷物収集
ユーザー maspymaspy
提出日時 2020-03-21 00:02:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,183 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 79,732 KB
最終ジャッジ日時 2024-05-09 09:51:18
合計ジャッジ時間 41,668 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 623 ms
44,092 KB
testcase_01 AC 536 ms
43,960 KB
testcase_02 AC 531 ms
44,220 KB
testcase_03 AC 537 ms
44,344 KB
testcase_04 AC 930 ms
79,572 KB
testcase_05 AC 924 ms
79,704 KB
testcase_06 AC 911 ms
79,444 KB
testcase_07 AC 926 ms
79,572 KB
testcase_08 AC 938 ms
79,416 KB
testcase_09 AC 919 ms
79,184 KB
testcase_10 AC 923 ms
79,316 KB
testcase_11 AC 921 ms
79,068 KB
testcase_12 AC 920 ms
79,064 KB
testcase_13 AC 915 ms
79,444 KB
testcase_14 AC 530 ms
43,828 KB
testcase_15 AC 541 ms
44,352 KB
testcase_16 AC 532 ms
44,088 KB
testcase_17 AC 535 ms
44,220 KB
testcase_18 AC 535 ms
44,352 KB
testcase_19 AC 532 ms
44,092 KB
testcase_20 AC 529 ms
44,340 KB
testcase_21 AC 531 ms
44,220 KB
testcase_22 AC 568 ms
44,220 KB
testcase_23 AC 531 ms
43,952 KB
testcase_24 AC 954 ms
65,696 KB
testcase_25 AC 1,101 ms
73,956 KB
testcase_26 AC 875 ms
55,352 KB
testcase_27 AC 600 ms
45,232 KB
testcase_28 AC 1,097 ms
71,636 KB
testcase_29 AC 894 ms
55,480 KB
testcase_30 AC 1,121 ms
72,220 KB
testcase_31 AC 737 ms
58,168 KB
testcase_32 AC 708 ms
52,284 KB
testcase_33 AC 812 ms
61,116 KB
testcase_34 AC 825 ms
63,288 KB
testcase_35 AC 1,016 ms
66,104 KB
testcase_36 AC 795 ms
62,908 KB
testcase_37 AC 871 ms
54,716 KB
testcase_38 AC 976 ms
67,800 KB
testcase_39 AC 718 ms
52,032 KB
testcase_40 AC 772 ms
54,460 KB
testcase_41 AC 1,183 ms
76,076 KB
testcase_42 AC 820 ms
57,920 KB
testcase_43 AC 933 ms
62,648 KB
testcase_44 AC 533 ms
79,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N, Q = map(int, readline().split())
event = []
S = 0
coef = 0
for _ in range(N):
    x, w = map(int, readline().split())
    event.append((x, w, 1))
    S += x * w
    coef -= w

X = map(int, read().split())
for i, x in enumerate(X):
    event.append((x, i, 2))

event.sort()

answer = [0] * Q
X = 0

for x, w, t in event:
    if t == 1:
        S += (x - X) * coef
        coef += 2 * w
        X = x
    else:
        i = w
        answer[i] = coef * (x - X) + S

print('\n'.join(map(str, answer)))
0