結果

問題 No.2408 Lakes and Fish
ユーザー やでな@競プロ
提出日時 2023-10-08 18:01:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 90,244 KB
最終ジャッジ日時 2024-07-26 18:10:30
合計ジャッジ時間 5,764 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
l = list(map(int,input().split()))

from bisect import *

ans = 0

for i in range(m):
    f,b,w = map(int,input().split())
    ind = bisect_left(l,f)
    if ind == 0:
        if l[ind] == f:
            ans += w
        else:
            ans += max(b,w-(l[0]-f))
    elif ind == n:
        if l[n-1] == f:
            ans += w
        else:
            ans += max(b,w-(f-l[n-1]))
    else:
        if l[ind] == f:
            ans += w
        else:
            tmp1 = w-(f-l[ind-1])
            tmp2 = w-(l[ind]-f)
            ans += max(b,tmp1,tmp2)
            
print(ans)
0