結果

問題 No.1012 荷物収集
ユーザー d9etd9et
提出日時 2020-03-20 22:29:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 589 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 130,984 KB
最終ジャッジ日時 2023-08-21 17:15:53
合計ジャッジ時間 15,224 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,492 KB
testcase_01 AC 71 ms
71,496 KB
testcase_02 AC 70 ms
71,316 KB
testcase_03 AC 72 ms
71,180 KB
testcase_04 AC 274 ms
118,952 KB
testcase_05 AC 270 ms
118,948 KB
testcase_06 AC 270 ms
118,848 KB
testcase_07 AC 269 ms
119,112 KB
testcase_08 AC 269 ms
119,096 KB
testcase_09 AC 266 ms
119,008 KB
testcase_10 AC 266 ms
118,984 KB
testcase_11 AC 273 ms
118,832 KB
testcase_12 AC 265 ms
119,052 KB
testcase_13 AC 267 ms
119,040 KB
testcase_14 AC 77 ms
75,192 KB
testcase_15 AC 86 ms
76,560 KB
testcase_16 AC 80 ms
75,212 KB
testcase_17 AC 85 ms
76,484 KB
testcase_18 AC 85 ms
76,612 KB
testcase_19 AC 77 ms
75,228 KB
testcase_20 AC 77 ms
71,152 KB
testcase_21 AC 81 ms
75,224 KB
testcase_22 AC 83 ms
75,260 KB
testcase_23 AC 81 ms
75,312 KB
testcase_24 AC 383 ms
108,652 KB
testcase_25 AC 520 ms
123,440 KB
testcase_26 AC 388 ms
105,536 KB
testcase_27 AC 167 ms
83,284 KB
testcase_28 AC 530 ms
110,092 KB
testcase_29 AC 496 ms
118,072 KB
testcase_30 AC 581 ms
116,900 KB
testcase_31 AC 173 ms
89,448 KB
testcase_32 AC 212 ms
87,560 KB
testcase_33 AC 233 ms
91,264 KB
testcase_34 AC 222 ms
93,060 KB
testcase_35 AC 483 ms
114,060 KB
testcase_36 AC 191 ms
90,584 KB
testcase_37 AC 475 ms
108,400 KB
testcase_38 AC 397 ms
102,376 KB
testcase_39 AC 243 ms
89,016 KB
testcase_40 AC 250 ms
89,704 KB
testcase_41 AC 589 ms
130,984 KB
testcase_42 AC 283 ms
97,692 KB
testcase_43 AC 422 ms
110,880 KB
testcase_44 AC 72 ms
71,164 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