結果

問題 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 ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 291 ms
コンパイル使用メモリ 85,496 KB
実行使用メモリ 112,236 KB
最終ジャッジ日時 2026-03-07 00:28:43
合計ジャッジ時間 4,438 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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