結果

問題 No.2408 Lakes and Fish
ユーザー Meso Meso
提出日時 2025-05-26 19:54:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 548 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 21,756 KB
最終ジャッジ日時 2025-05-26 19:54:23
合計ジャッジ時間 9,065 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

n, m = map(int, input().split())
L = sorted(map(int, input().split()))  
s, c = 0, 0

for _ in range(m):
    f, b, w = map(int, input().split())
    i = bisect_left(L, f)  

    distance = float('inf')
    if i < n:  
        distance = abs(f - L[i])
    if i > 0:  
        distance = min(distance, abs(f - L[i - 1]))

    if distance == 0:
        s += w
    else:
        if w - distance > b:
            s += w
            c += distance
        else:
            s += b

print(s - c)

0