結果

問題 No.2408 Lakes and Fish
ユーザー detteiuu
提出日時 2024-12-22 05:11:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 91,520 KB
最終ジャッジ日時 2024-12-22 05:11:54
合計ジャッジ時間 5,487 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

N, M = map(int, input().split())
L = list(map(int, input().split()))
FBW = [list(map(int, input().split())) for _ in range(M)]

ans = 0
for F, B, W in FBW:
    b = bisect_left(L, F)
    if b < N and L[b] == F:
        ans += W
        continue
    MAX = B
    if 1 <= b:
        MAX = max(MAX, W-(F-L[b-1]))
    if b < N:
        MAX = max(MAX, W-(L[b]-F))
    ans += MAX

print(ans)
0