結果

問題 No.2408 Lakes and Fish
ユーザー やでな@競プロやでな@競プロ
提出日時 2023-10-08 18:01:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 87,392 KB
実行使用メモリ 91,704 KB
最終ジャッジ日時 2023-10-08 18:01:28
合計ジャッジ時間 6,840 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,692 KB
testcase_01 AC 67 ms
71,196 KB
testcase_02 AC 70 ms
71,676 KB
testcase_03 AC 64 ms
71,384 KB
testcase_04 AC 186 ms
91,176 KB
testcase_05 AC 180 ms
91,232 KB
testcase_06 AC 189 ms
90,588 KB
testcase_07 AC 209 ms
91,560 KB
testcase_08 AC 231 ms
91,640 KB
testcase_09 AC 222 ms
91,608 KB
testcase_10 AC 216 ms
91,704 KB
testcase_11 AC 164 ms
81,516 KB
testcase_12 AC 182 ms
87,980 KB
testcase_13 AC 136 ms
80,480 KB
testcase_14 AC 157 ms
81,504 KB
testcase_15 AC 195 ms
86,792 KB
testcase_16 AC 134 ms
83,152 KB
testcase_17 AC 130 ms
79,000 KB
testcase_18 AC 157 ms
84,896 KB
testcase_19 AC 189 ms
83,184 KB
testcase_20 AC 205 ms
78,936 KB
testcase_21 AC 190 ms
84,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
l = list(map(int,input().split()))

from bisect import *

ans = 0

for i in range(m):
    f,b,w = map(int,input().split())
    ind = bisect_left(l,f)
    if ind == 0:
        if l[ind] == f:
            ans += w
        else:
            ans += max(b,w-(l[0]-f))
    elif ind == n:
        if l[n-1] == f:
            ans += w
        else:
            ans += max(b,w-(f-l[n-1]))
    else:
        if l[ind] == f:
            ans += w
        else:
            tmp1 = w-(f-l[ind-1])
            tmp2 = w-(l[ind]-f)
            ans += max(b,tmp1,tmp2)
            
print(ans)
0