結果

問題 No.2408 Lakes and Fish
ユーザー mymelochanmymelochan
提出日時 2023-08-11 21:34:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 90,624 KB
最終ジャッジ日時 2024-04-29 12:24:02
合計ジャッジ時間 4,565 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
54,272 KB
testcase_01 AC 53 ms
54,016 KB
testcase_02 AC 51 ms
54,528 KB
testcase_03 AC 49 ms
53,888 KB
testcase_04 AC 164 ms
89,984 KB
testcase_05 AC 158 ms
90,228 KB
testcase_06 AC 166 ms
89,600 KB
testcase_07 AC 184 ms
90,624 KB
testcase_08 AC 192 ms
90,112 KB
testcase_09 AC 185 ms
90,216 KB
testcase_10 AC 193 ms
90,112 KB
testcase_11 AC 135 ms
79,424 KB
testcase_12 AC 163 ms
86,528 KB
testcase_13 AC 105 ms
78,592 KB
testcase_14 AC 133 ms
79,488 KB
testcase_15 AC 173 ms
85,760 KB
testcase_16 AC 115 ms
82,560 KB
testcase_17 AC 114 ms
77,056 KB
testcase_18 AC 144 ms
84,864 KB
testcase_19 AC 175 ms
82,304 KB
testcase_20 AC 168 ms
76,672 KB
testcase_21 AC 178 ms
84,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations
from math import sin,cos
#from math import isqrt #DO NOT USE PyPy

ipt = sys.stdin.readline
iin = lambda :int(ipt())
lmin = lambda :list(map(int,ipt().split()))

#############################################################

N,M = lmin()
L = lmin()

ans = 0
for _ in range(M):
    F,B,W = lmin()
    t = B
    idx = bisect_left(L,F)
    if idx != 0:
        t = max(t,W-abs(F-L[idx-1]))
    if idx != N:
        t = max(t,W-abs(F-L[idx]))
    ans += t
print(ans)
0