結果
問題 |
No.1012 荷物収集
|
ユーザー |
![]() |
提出日時 | 2020-12-09 16:00:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 667 ms / 2,000 ms |
コード長 | 806 bytes |
コンパイル時間 | 582 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 121,984 KB |
最終ジャッジ日時 | 2024-09-19 01:15:33 |
合計ジャッジ時間 | 15,796 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N,Q = MI() X = [] a,b = 0,0 c,d = 0,0 for _ in range(N): x,w = MI() X.append((x,w,0)) b += w d += x*w Y = LI() for i in range(Q): X.append((Y[i],0,i)) X.sort() ANS = [0]*Q for x,w,i in X: if w == 0: ANS[i] = x*(a-b)-(c-d) else: a += w b -= w c += x*w d -= x*w print(*ANS,sep='\n')