結果

問題 No.1012 荷物収集
ユーザー convexineqconvexineq
提出日時 2020-03-20 22:04:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 382 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 901 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 105,044 KB
最終ジャッジ日時 2023-08-21 16:42:55
合計ジャッジ時間 13,185 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,248 KB
testcase_01 AC 75 ms
71,352 KB
testcase_02 AC 76 ms
71,204 KB
testcase_03 AC 76 ms
71,308 KB
testcase_04 AC 230 ms
102,604 KB
testcase_05 AC 229 ms
102,520 KB
testcase_06 AC 226 ms
102,980 KB
testcase_07 AC 225 ms
102,656 KB
testcase_08 AC 228 ms
102,612 KB
testcase_09 AC 231 ms
102,752 KB
testcase_10 AC 223 ms
102,480 KB
testcase_11 AC 226 ms
102,732 KB
testcase_12 AC 229 ms
102,648 KB
testcase_13 AC 228 ms
102,668 KB
testcase_14 AC 80 ms
75,260 KB
testcase_15 AC 88 ms
76,128 KB
testcase_16 AC 83 ms
75,416 KB
testcase_17 AC 90 ms
75,908 KB
testcase_18 AC 88 ms
75,652 KB
testcase_19 AC 80 ms
75,292 KB
testcase_20 AC 79 ms
71,204 KB
testcase_21 AC 84 ms
75,284 KB
testcase_22 AC 85 ms
75,348 KB
testcase_23 AC 83 ms
75,456 KB
testcase_24 AC 270 ms
95,244 KB
testcase_25 AC 354 ms
101,988 KB
testcase_26 AC 263 ms
95,116 KB
testcase_27 AC 148 ms
80,480 KB
testcase_28 AC 336 ms
105,044 KB
testcase_29 AC 300 ms
99,720 KB
testcase_30 AC 363 ms
101,644 KB
testcase_31 AC 160 ms
84,012 KB
testcase_32 AC 180 ms
82,396 KB
testcase_33 AC 198 ms
85,936 KB
testcase_34 AC 194 ms
85,960 KB
testcase_35 AC 326 ms
95,688 KB
testcase_36 AC 178 ms
88,752 KB
testcase_37 AC 304 ms
99,920 KB
testcase_38 AC 288 ms
91,868 KB
testcase_39 AC 201 ms
85,924 KB
testcase_40 AC 205 ms
87,244 KB
testcase_41 AC 382 ms
100,396 KB
testcase_42 AC 222 ms
86,192 KB
testcase_43 AC 296 ms
99,900 KB
testcase_44 AC 75 ms
71,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,Q = [int(i) for i in readline().split()]
xw = [[int(i) for i in readline().split()] for _ in range(n)]
qs = [int(i) for i in readline().split()]

xw.sort(key = lambda x:x[0])

c = -sum(xwi[1] for xwi in xw)
xs = [xwi[0] for xwi in xw] + [10**10]
x0 = xw[0][0]
v = sum((x-x0)*w for x,w in xw)

coeff = [c]
val = []
for i,(x,w) in enumerate(xw):
    c += 2*w
    coeff.append(c)
    val.append(v)    
    v += c*(xs[i+1]-xs[i])

xs.pop()
v = val[-1]
from bisect import bisect_left
for q in qs:
    idx = bisect_left(xs,q)
    if idx < n:
        print(val[idx]-coeff[idx]*(xs[idx]-q))        
    else:
        print(v+c*(q-xs[-1]))
    
    
    







0