結果

問題 No.2408 Lakes and Fish
ユーザー ntuda
提出日時 2023-08-12 11:29:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 91,608 KB
最終ジャッジ日時 2024-11-19 12:09:25
合計ジャッジ時間 5,256 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

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:
    a = bisect_left(L, f)
    tmp = b
    if a > 0:
        tmp = max(tmp, w - f + L[a - 1])
    if a < N:
        tmp = max(tmp, w - L[a] + f)
    ans += tmp
print(ans)
0