結果
問題 | No.2408 Lakes and Fish |
ユーザー | ryomac |
提出日時 | 2023-08-11 21:43:20 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 594 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 96,640 KB |
最終ジャッジ日時 | 2024-04-29 12:34:37 |
合計ジャッジ時間 | 4,342 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
57,088 KB |
testcase_01 | AC | 42 ms
51,968 KB |
testcase_02 | AC | 42 ms
52,224 KB |
testcase_03 | AC | 42 ms
52,096 KB |
testcase_04 | TLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
from bisect import bisect_left, bisect_right 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 i in range(M): f, b, w = FBW[i] if f in L: ans += w else: idx = bisect_left(L, f) if idx == 0: cost = L[0] - f elif idx == N: cost = f - L[-1] else: near = L[bisect_left(L, f)] near2 = L[bisect_right(L, f) - 1] cost = min(abs(f - near), abs(f - near2)) ans += max(w - cost, b) print(ans)