結果

問題 No.1012 荷物収集
ユーザー d9etd9et
提出日時 2020-03-20 22:29:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 545 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 123,392 KB
最終ジャッジ日時 2024-05-08 22:45:15
合計ジャッジ時間 12,880 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,224 KB
testcase_01 AC 41 ms
52,224 KB
testcase_02 AC 40 ms
52,096 KB
testcase_03 AC 41 ms
52,096 KB
testcase_04 AC 250 ms
114,944 KB
testcase_05 AC 247 ms
115,284 KB
testcase_06 AC 247 ms
115,456 KB
testcase_07 AC 245 ms
115,352 KB
testcase_08 AC 244 ms
115,172 KB
testcase_09 AC 244 ms
115,072 KB
testcase_10 AC 246 ms
114,984 KB
testcase_11 AC 238 ms
115,200 KB
testcase_12 AC 238 ms
114,944 KB
testcase_13 AC 246 ms
115,128 KB
testcase_14 AC 46 ms
58,880 KB
testcase_15 AC 58 ms
63,988 KB
testcase_16 AC 52 ms
60,160 KB
testcase_17 AC 58 ms
63,360 KB
testcase_18 AC 57 ms
62,592 KB
testcase_19 AC 45 ms
58,496 KB
testcase_20 AC 47 ms
53,504 KB
testcase_21 AC 50 ms
60,416 KB
testcase_22 AC 54 ms
61,056 KB
testcase_23 AC 50 ms
59,904 KB
testcase_24 AC 336 ms
104,264 KB
testcase_25 AC 469 ms
116,824 KB
testcase_26 AC 354 ms
104,832 KB
testcase_27 AC 148 ms
81,972 KB
testcase_28 AC 494 ms
113,280 KB
testcase_29 AC 465 ms
119,512 KB
testcase_30 AC 534 ms
121,204 KB
testcase_31 AC 152 ms
85,296 KB
testcase_32 AC 186 ms
85,248 KB
testcase_33 AC 207 ms
89,576 KB
testcase_34 AC 199 ms
87,740 KB
testcase_35 AC 435 ms
106,740 KB
testcase_36 AC 171 ms
92,220 KB
testcase_37 AC 430 ms
111,104 KB
testcase_38 AC 361 ms
100,160 KB
testcase_39 AC 222 ms
87,748 KB
testcase_40 AC 219 ms
90,240 KB
testcase_41 AC 545 ms
123,392 KB
testcase_42 AC 261 ms
94,740 KB
testcase_43 AC 390 ms
111,644 KB
testcase_44 AC 41 ms
52,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from itertools import accumulate
import bisect
n,q = map(int,input().split())
xw = [list(map(int,input().split())) for i in range(n)]
xw.append([0,0])
xw.append([10**9,0])
xw.sort()
acc = list(accumulate(list(zip(*xw))[1]))
ls = []
x = xw[0][0]
cost = 0
n += 2
for i in range(1,n):
  x1,w1 = xw[i]
  cost += (x1-x)*w1
ls.append((x,cost))
for i in range(1,n):
  pos,w = xw[i]
  x,cost = ls[-1]
  cost += acc[i-1]*(pos-x)
  cost -= (acc[n-1]-acc[i-1])*(pos-x)
  ls.append((pos,cost))
xls = list(zip(*xw))[0]
query = list(map(int,input().split()))
ans = []
for i in query:
  x = bisect.bisect_left(xls,i)
  x1,c1 = ls[x-1]
  x2,c2 = ls[x]
  dc = c2-c1
  print(c1+dc*(i-x1)//(x2-x1))
0