結果
問題 | No.2408 Lakes and Fish |
ユーザー | ryohei22 |
提出日時 | 2023-08-11 21:31:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 288 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 106,496 KB |
最終ジャッジ日時 | 2024-04-29 12:20:29 |
合計ジャッジ時間 | 5,847 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
51,968 KB |
testcase_01 | AC | 42 ms
51,968 KB |
testcase_02 | AC | 42 ms
52,096 KB |
testcase_03 | AC | 41 ms
51,712 KB |
testcase_04 | AC | 253 ms
105,856 KB |
testcase_05 | AC | 247 ms
105,984 KB |
testcase_06 | AC | 256 ms
106,112 KB |
testcase_07 | AC | 288 ms
106,368 KB |
testcase_08 | AC | 288 ms
105,984 KB |
testcase_09 | AC | 283 ms
105,984 KB |
testcase_10 | AC | 285 ms
106,496 KB |
testcase_11 | AC | 197 ms
84,244 KB |
testcase_12 | AC | 230 ms
99,968 KB |
testcase_13 | AC | 139 ms
81,920 KB |
testcase_14 | AC | 174 ms
84,480 KB |
testcase_15 | AC | 250 ms
97,024 KB |
testcase_16 | AC | 155 ms
89,856 KB |
testcase_17 | AC | 146 ms
80,512 KB |
testcase_18 | AC | 191 ms
94,336 KB |
testcase_19 | AC | 242 ms
90,496 KB |
testcase_20 | AC | 242 ms
86,784 KB |
testcase_21 | AC | 249 ms
94,208 KB |
ソースコード
def binary_search(T: list, t: int) -> int: # T: ソートされたリスト l, r = 0, len(T) while l < r: m = (l + r) // 2 if T[m] < t: l = m + 1 else: r = m return l N, M = map(int, input().split()) L = sorted(list(map(int, input().split()))) s = set(L) F = [list(map(int, input().split())) for _ in range(M)] ans = 0 for f, b, w in F: idx = binary_search(L, f) mi = float('inf') if idx < N: mi = min(mi, abs(L[idx]-f)) if idx + 1 < N: mi = min(mi, abs(L[idx+1]-f)) if 0 <= idx - 1: mi = min(mi, abs(L[idx-1]-f)) ans += max(b, w-mi) print(ans)