結果

問題 No.2408 Lakes and Fish
ユーザー flippergo
提出日時 2024-12-03 08:08:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,588 KB
実行使用メモリ 93,952 KB
最終ジャッジ日時 2024-12-03 08:09:01
合計ジャッジ時間 6,400 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
N,M = map(int,input().split())
INFTY = 10**9
L = [-INFTY]+list(map(int,input().split()))+[2*INFTY]
A = [list(map(int,input().split())) for _ in range(M)]
ans = 0
for j in range(M):
    f,b,w = A[j]
    ind = bisect_left(L,f)
    d = min(abs(L[ind]-f),abs(L[ind-1]-f))
    if d==0:
        ans += w
    else:
        if w-b-d>0:
            ans += w-d
        else:
            ans += b
print(ans)
0