結果

問題 No.1012 荷物収集
ユーザー amyuamyu
提出日時 2020-03-20 22:30:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 609 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 43,384 KB
最終ジャッジ日時 2024-12-15 06:48:08
合計ジャッジ時間 14,401 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
from bisect import bisect
n,q=map(int,input().split())
l=[tuple(map(int,input().split())) for i in range(n)]
l.sort()
aw=[0]
axw=[0]
for x,w in l:
    aw.append(aw[-1]+w)
    axw.append(axw[-1]+x*w)
x=list(map(int,input().split()))
for i in x:
    t=bisect(l,(i,0))
    print(i*aw[t]-axw[t]+axw[n]-axw[t]-i*(aw[n]-aw[t]))
0