結果

問題 No.2408 Lakes and Fish
ユーザー かとぅー ☆かとぅー ☆
提出日時 2023-09-04 21:56:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 106,812 KB
最終ジャッジ日時 2024-06-22 19:24:06
合計ジャッジ時間 5,850 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
from collections import defaultdict

N, M = map(int, input().split())
L = list(map(int, input().split())) 
L.sort()
mi = L[0]
ma = L[-1]
d = defaultdict(int) 
for i in range(N):
    d[L[i]] += 1
ans = 0 
for i in range(M):
    f, b, w = map(int, input().split())  
    if f in d:
        ans += w     
    else:
        if f > ma:
            ans += max(w-abs(f-ma), b)
        elif mi > f:
            ans += max(w-abs(f-mi), b)
        else:
            e = bisect_left(L, f)          
            ans += max(w-abs(L[e]-f), w-abs(L[e-1]), b)

print(ans)
0