結果

問題 No.1012 荷物収集
ユーザー nagitaosunagitaosu
提出日時 2020-03-20 22:53:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 118,748 KB
最終ジャッジ日時 2023-08-21 18:04:42
合計ジャッジ時間 11,631 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,312 KB
testcase_01 AC 76 ms
71,312 KB
testcase_02 AC 76 ms
71,044 KB
testcase_03 AC 75 ms
71,224 KB
testcase_04 AC 216 ms
115,960 KB
testcase_05 AC 213 ms
115,984 KB
testcase_06 AC 207 ms
115,856 KB
testcase_07 AC 207 ms
116,360 KB
testcase_08 AC 201 ms
116,136 KB
testcase_09 AC 203 ms
116,252 KB
testcase_10 AC 203 ms
115,976 KB
testcase_11 AC 205 ms
116,100 KB
testcase_12 AC 203 ms
116,320 KB
testcase_13 AC 199 ms
116,132 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 77 ms
71,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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)
0