結果

問題 No.2408 Lakes and Fish
コンテスト
ユーザー かとぅー ☆
提出日時 2023-09-04 21:56:09
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 586 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 248 ms
コンパイル使用メモリ 96,100 KB
実行使用メモリ 113,196 KB
最終ジャッジ日時 2026-07-27 08:33:00
合計ジャッジ時間 6,567 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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