結果

問題 No.2408 Lakes and Fish
ユーザー AngrySadEightAngrySadEight
提出日時 2023-07-08 15:53:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 96,640 KB
最終ジャッジ日時 2024-04-29 11:54:35
合計ジャッジ時間 4,838 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,712 KB
testcase_01 AC 38 ms
51,968 KB
testcase_02 AC 37 ms
51,968 KB
testcase_03 AC 35 ms
51,840 KB
testcase_04 AC 161 ms
95,744 KB
testcase_05 AC 165 ms
96,128 KB
testcase_06 AC 200 ms
95,616 KB
testcase_07 AC 198 ms
96,512 KB
testcase_08 AC 202 ms
96,256 KB
testcase_09 AC 199 ms
96,640 KB
testcase_10 AC 194 ms
96,640 KB
testcase_11 AC 140 ms
81,408 KB
testcase_12 AC 170 ms
91,776 KB
testcase_13 AC 107 ms
79,616 KB
testcase_14 AC 126 ms
81,748 KB
testcase_15 AC 170 ms
89,496 KB
testcase_16 AC 113 ms
84,608 KB
testcase_17 AC 105 ms
77,312 KB
testcase_18 AC 138 ms
87,424 KB
testcase_19 AC 166 ms
84,608 KB
testcase_20 AC 162 ms
76,800 KB
testcase_21 AC 170 ms
87,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

INF = 10 ** 17

N, M = map(int, input().split())
L = list(map(int, input().split()))
Li = []
Li.append(-INF)
for x in L:
    Li.append(x)
Li.append(INF)
ans = 0
for i in range(M):
    F, B, W = map(int, input().split())
    idx = bisect.bisect_left(Li, F)
    min_dist = abs(F - Li[idx])
    idx -= 1
    min_dist = min(min_dist, abs(F - Li[idx]))
    if min_dist < W - B:
        ans += W - min_dist
    else:
        ans += B
print(ans)
0