結果

問題 No.2408 Lakes and Fish
コンテスト
ユーザー timi
提出日時 2023-08-12 11:55:08
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 345 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 148 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 113,900 KB
最終ジャッジ日時 2026-05-13 19:37:19
合計ジャッジ時間 4,157 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M=map(int, input().split())
L=list(map(int, input().split()))
A=L.copy()
A.append(-10**12)
A.append(10**12)
A=sorted(A)
LL=set(L)
import bisect
ans=0
for i in range(M):
  f,b,w=map(int, input().split())
  if f in LL:
    ans+=w 
  else:
    d=bisect.bisect_left(A,f)
    x,y=A[d-1],A[d]
    p=max(b,w-abs(f-x),w-abs(f-y))
    ans+=p
print(ans)
0