結果

問題 No.2408 Lakes and Fish
ユーザー FromBooskaFromBooska
提出日時 2023-08-12 04:40:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 95,460 KB
最終ジャッジ日時 2024-04-29 19:13:50
合計ジャッジ時間 5,954 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,968 KB
testcase_01 AC 35 ms
51,840 KB
testcase_02 AC 38 ms
51,840 KB
testcase_03 AC 41 ms
51,968 KB
testcase_04 AC 173 ms
94,404 KB
testcase_05 AC 176 ms
94,436 KB
testcase_06 AC 195 ms
93,812 KB
testcase_07 AC 247 ms
94,976 KB
testcase_08 AC 266 ms
94,912 KB
testcase_09 AC 263 ms
95,276 KB
testcase_10 AC 259 ms
95,460 KB
testcase_11 AC 181 ms
81,848 KB
testcase_12 AC 225 ms
90,496 KB
testcase_13 AC 144 ms
80,344 KB
testcase_14 AC 170 ms
81,792 KB
testcase_15 AC 200 ms
88,404 KB
testcase_16 AC 150 ms
83,712 KB
testcase_17 AC 149 ms
78,956 KB
testcase_18 AC 150 ms
87,040 KB
testcase_19 AC 251 ms
84,412 KB
testcase_20 AC 209 ms
78,336 KB
testcase_21 AC 202 ms
86,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 一番近い水までの距離を見て一匹ずつどうするか決めればいいか
# bisect 

N, M = map(int, input().split())
INF = 10**20
L = [-INF]+list(map(int, input().split()))+[INF]

from bisect import *
ans = 0
for i in range(M):
    f, b, w = map(int, input().split())
    lower = L[bisect_left(L, f)-1]
    higher = L[bisect_left(L, f)]
    d = min(higher-f, f-lower)
    if d == 0:
        calc = w
    else:
        calc = max(b, w-d)
    ans += calc
    #print(f, lower, higher, d, calc)
print(ans)


0