結果
| 問題 |
No.1012 荷物収集
|
| コンテスト | |
| ユーザー |
nagitaosu
|
| 提出日時 | 2020-03-20 22:53:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 865 bytes |
| コンパイル時間 | 153 ms |
| コンパイル使用メモリ | 82,484 KB |
| 実行使用メモリ | 116,224 KB |
| 最終ジャッジ日時 | 2024-12-15 07:42:28 |
| 合計ジャッジ時間 | 7,383 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 11 WA * 30 |
ソースコード
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import bisect
n, q = map(int, input().split())
places = []
r_x = [0] * n
r_1 = [0] * n
l_x = [0] * n
l_1 = [0] * n
for i in range(n):
x, w = map(int, input().split())
places.append(x)
r_x[i] = w
l_x[i] = -w
r_1[i] = -(x * w)
l_1[i] = x * w
r_x_cum = [0]
r_1_cum = [0]
for item in r_x:
r_x_cum.append(r_x_cum[-1] + item)
for item in r_1:
r_1_cum.append(r_1_cum[-1] + item)
l_x_cum = [0]
l_1_cum = [0]
for item in l_x[::-1]:
l_x_cum.append(l_x_cum[-1] + item)
for item in l_1[::-1]:
l_1_cum.append(l_1_cum[-1] + item)
q = [int(item) for item in input().split()]
for np in q:
r_index = bisect.bisect_left(places, np)
l_index = n - r_index
ans = r_x_cum[r_index] * np + r_1_cum[r_index]
ans += l_x_cum[l_index] * np + l_1_cum[l_index]
print(ans)
nagitaosu