結果

問題 No.1012 荷物収集
ユーザー takakintakakin
提出日時 2020-03-22 20:03:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 595 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 44,148 KB
最終ジャッジ日時 2024-06-07 15:17:42
合計ジャッジ時間 16,592 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,624 KB
testcase_01 AC 31 ms
10,624 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 29 ms
10,624 KB
testcase_04 AC 477 ms
43,980 KB
testcase_05 AC 471 ms
44,012 KB
testcase_06 AC 470 ms
44,148 KB
testcase_07 AC 476 ms
43,976 KB
testcase_08 AC 474 ms
43,980 KB
testcase_09 AC 474 ms
43,976 KB
testcase_10 AC 480 ms
43,212 KB
testcase_11 AC 481 ms
43,336 KB
testcase_12 AC 466 ms
44,108 KB
testcase_13 AC 480 ms
44,104 KB
testcase_14 AC 30 ms
10,880 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 29 ms
10,752 KB
testcase_17 AC 29 ms
10,880 KB
testcase_18 AC 29 ms
10,752 KB
testcase_19 AC 29 ms
10,752 KB
testcase_20 AC 30 ms
10,880 KB
testcase_21 AC 31 ms
10,880 KB
testcase_22 AC 32 ms
10,880 KB
testcase_23 AC 31 ms
10,880 KB
testcase_24 AC 369 ms
30,344 KB
testcase_25 AC 519 ms
38,072 KB
testcase_26 AC 327 ms
29,240 KB
testcase_27 AC 94 ms
15,200 KB
testcase_28 AC 523 ms
38,368 KB
testcase_29 AC 394 ms
32,676 KB
testcase_30 AC 566 ms
41,052 KB
testcase_31 AC 152 ms
18,504 KB
testcase_32 AC 173 ms
19,256 KB
testcase_33 AC 226 ms
22,392 KB
testcase_34 AC 226 ms
22,712 KB
testcase_35 AC 446 ms
34,952 KB
testcase_36 AC 190 ms
20,828 KB
testcase_37 AC 364 ms
31,516 KB
testcase_38 AC 406 ms
31,840 KB
testcase_39 AC 199 ms
21,504 KB
testcase_40 AC 222 ms
22,176 KB
testcase_41 AC 595 ms
41,600 KB
testcase_42 AC 268 ms
24,628 KB
testcase_43 AC 378 ms
31,508 KB
testcase_44 AC 30 ms
10,752 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