結果

問題 No.2408 Lakes and Fish
ユーザー miya145592miya145592
提出日時 2023-08-11 21:53:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 91,520 KB
最終ジャッジ日時 2024-04-29 12:47:12
合計ジャッジ時間 5,290 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,712 KB
testcase_01 AC 42 ms
52,224 KB
testcase_02 AC 46 ms
51,968 KB
testcase_03 AC 41 ms
51,712 KB
testcase_04 AC 217 ms
90,880 KB
testcase_05 AC 219 ms
91,008 KB
testcase_06 AC 233 ms
90,752 KB
testcase_07 AC 266 ms
91,520 KB
testcase_08 AC 256 ms
91,392 KB
testcase_09 AC 260 ms
91,392 KB
testcase_10 AC 256 ms
91,520 KB
testcase_11 AC 182 ms
83,072 KB
testcase_12 AC 212 ms
87,552 KB
testcase_13 AC 126 ms
78,848 KB
testcase_14 AC 162 ms
81,408 KB
testcase_15 AC 229 ms
86,656 KB
testcase_16 AC 138 ms
82,304 KB
testcase_17 AC 134 ms
79,232 KB
testcase_18 AC 172 ms
85,248 KB
testcase_19 AC 223 ms
86,076 KB
testcase_20 AC 230 ms
86,784 KB
testcase_21 AC 230 ms
86,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N, M = map(int, input().split())
L = list(map(int, input().split()))
FBW = [list(map(int, input().split())) for _ in range(M)]
ans = 0
for f, b, w in FBW:
    pos = bisect.bisect_left(L, f)
    if pos<N:
        if L[pos]==f:
            ans += w
        else:
            c = L[pos]-f
            if pos>0:
                c = min(c, f-L[pos-1])
            ans += max(b, w-c)
    else:
        c = f-L[pos-1]
        ans += max(b, w-c)
print(ans)
0