結果

問題 No.1012 荷物収集
ユーザー titiatitia
提出日時 2020-03-21 04:38:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 973 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 48,452 KB
最終ジャッジ日時 2024-05-09 18:37:21
合計ジャッジ時間 20,193 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
11,008 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 24 ms
10,880 KB
testcase_03 AC 24 ms
10,752 KB
testcase_04 AC 680 ms
48,324 KB
testcase_05 AC 672 ms
48,320 KB
testcase_06 AC 679 ms
48,292 KB
testcase_07 AC 671 ms
48,452 KB
testcase_08 AC 666 ms
48,448 KB
testcase_09 AC 674 ms
48,300 KB
testcase_10 AC 764 ms
48,324 KB
testcase_11 AC 667 ms
48,172 KB
testcase_12 AC 693 ms
48,188 KB
testcase_13 AC 690 ms
48,292 KB
testcase_14 AC 26 ms
10,752 KB
testcase_15 AC 27 ms
11,136 KB
testcase_16 AC 26 ms
10,880 KB
testcase_17 AC 27 ms
10,752 KB
testcase_18 AC 26 ms
10,752 KB
testcase_19 AC 28 ms
10,752 KB
testcase_20 AC 27 ms
10,880 KB
testcase_21 AC 27 ms
11,008 KB
testcase_22 AC 27 ms
10,880 KB
testcase_23 AC 26 ms
10,880 KB
testcase_24 AC 519 ms
30,880 KB
testcase_25 AC 705 ms
40,824 KB
testcase_26 AC 433 ms
35,044 KB
testcase_27 AC 115 ms
17,012 KB
testcase_28 AC 751 ms
43,464 KB
testcase_29 AC 526 ms
42,984 KB
testcase_30 AC 771 ms
46,392 KB
testcase_31 AC 202 ms
18,416 KB
testcase_32 AC 227 ms
19,476 KB
testcase_33 AC 307 ms
20,760 KB
testcase_34 AC 309 ms
21,312 KB
testcase_35 AC 623 ms
39,832 KB
testcase_36 AC 253 ms
20,448 KB
testcase_37 AC 472 ms
39,948 KB
testcase_38 AC 575 ms
33,564 KB
testcase_39 AC 295 ms
23,616 KB
testcase_40 AC 328 ms
22,784 KB
testcase_41 AC 973 ms
46,296 KB
testcase_42 AC 355 ms
25,336 KB
testcase_43 AC 541 ms
35,508 KB
testcase_44 AC 27 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int,input().split())
B=[tuple(map(int,input().split())) for i in range(N)]
X=list(map(int,input().split()))

B.append((0,0))
B.append((1<<30,0))

N+=2

from operator import itemgetter
B.sort(key=itemgetter(0))

LSUM=[0]
for x,w in B:
    LSUM.append(LSUM[-1]+w)

LC=[0]
for i in range(1,N):
    LC.append(LC[-1]+(B[i][0]-B[i-1][0])*LSUM[i])

RSUM=[0]
for x,w in B[::-1]:
    RSUM.append(RSUM[-1]+w)

RC=[0]
for i in range(N-1,0,-1):
    RC.append(RC[-1]+(B[i][0]-B[i-1][0])*RSUM[N-i])

LC.append(0)
RC.append(0)
import bisect

for x in X:
    t=bisect.bisect_left(B,(x,1<<30))
    print(LC[t-1]+LSUM[t]*(x-B[t-1][0])+RC[N-1-t]+RSUM[N-t]*(B[t][0]-x))
0