結果

問題 No.2408 Lakes and Fish
ユーザー miya145592
提出日時 2023-08-11 21:53:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 91,512 KB
最終ジャッジ日時 2024-11-18 16:01:56
合計ジャッジ時間 4,874 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
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:
    pos = bisect.bisect_left(L, f)
    if pos<N:
        if L[pos]==f:
            ans += w
        else:
            c = L[pos]-f
            if pos>0:
                c = min(c, f-L[pos-1])
            ans += max(b, w-c)
    else:
        c = f-L[pos-1]
        ans += max(b, w-c)
print(ans)
0