結果

問題 No.1012 荷物収集
ユーザー takakintakakin
提出日時 2020-03-22 20:03:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 516 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 43,188 KB
最終ジャッジ日時 2023-08-26 19:45:15
合計ジャッジ時間 16,751 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,132 KB
testcase_01 AC 14 ms
8,176 KB
testcase_02 AC 14 ms
8,292 KB
testcase_03 AC 14 ms
8,056 KB
testcase_04 AC 394 ms
43,188 KB
testcase_05 AC 438 ms
42,996 KB
testcase_06 AC 400 ms
43,004 KB
testcase_07 AC 393 ms
42,940 KB
testcase_08 AC 398 ms
43,084 KB
testcase_09 AC 405 ms
43,072 KB
testcase_10 AC 405 ms
43,076 KB
testcase_11 AC 404 ms
43,148 KB
testcase_12 AC 411 ms
43,000 KB
testcase_13 AC 400 ms
43,068 KB
testcase_14 AC 16 ms
8,364 KB
testcase_15 AC 17 ms
8,172 KB
testcase_16 AC 17 ms
8,224 KB
testcase_17 AC 17 ms
8,156 KB
testcase_18 AC 16 ms
8,140 KB
testcase_19 AC 15 ms
8,272 KB
testcase_20 AC 16 ms
8,360 KB
testcase_21 AC 15 ms
8,256 KB
testcase_22 AC 15 ms
8,200 KB
testcase_23 AC 15 ms
8,232 KB
testcase_24 AC 310 ms
27,724 KB
testcase_25 AC 449 ms
35,436 KB
testcase_26 AC 264 ms
26,396 KB
testcase_27 AC 70 ms
12,428 KB
testcase_28 AC 435 ms
35,940 KB
testcase_29 AC 310 ms
30,304 KB
testcase_30 AC 491 ms
38,420 KB
testcase_31 AC 137 ms
15,896 KB
testcase_32 AC 144 ms
16,796 KB
testcase_33 AC 193 ms
19,812 KB
testcase_34 AC 186 ms
20,112 KB
testcase_35 AC 377 ms
32,520 KB
testcase_36 AC 162 ms
18,168 KB
testcase_37 AC 301 ms
28,868 KB
testcase_38 AC 351 ms
29,428 KB
testcase_39 AC 163 ms
18,776 KB
testcase_40 AC 175 ms
19,660 KB
testcase_41 AC 516 ms
38,788 KB
testcase_42 AC 249 ms
22,012 KB
testcase_43 AC 318 ms
29,036 KB
testcase_44 AC 15 ms
8,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,q=map(int,input().split())
X,XW=[],[]
tot_xw,tot_w=0,0
for _ in range(n):
  x,w=map(int,input().split())
  tot_xw+=x*w
  tot_w+=w
  XW.append((x,w))
  X.append(x)
XW.sort(key=lambda x:x[0])
X.sort()
A,B=[0]*(n+1),[0]*(n+1)
A[0]=-tot_w
B[0]=tot_xw
for i in range(n):
  A[i+1]=A[i]+2*XW[i][1]
  B[i+1]=B[i]-2*XW[i][0]*XW[i][1]

import bisect
Q=[int(i) for i in input().split()]
for q in Q:
  ind=bisect.bisect_left(X,q)
  print(A[ind]*q+B[ind])
0