結果

問題 No.2408 Lakes and Fish
ユーザー moharan627moharan627
提出日時 2023-08-11 21:30:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 94,744 KB
最終ジャッジ日時 2023-08-11 21:30:22
合計ジャッジ時間 5,680 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,828 KB
testcase_01 AC 92 ms
71,660 KB
testcase_02 AC 93 ms
71,704 KB
testcase_03 AC 91 ms
71,920 KB
testcase_04 AC 183 ms
93,932 KB
testcase_05 AC 181 ms
93,940 KB
testcase_06 AC 185 ms
93,036 KB
testcase_07 AC 214 ms
94,480 KB
testcase_08 AC 215 ms
94,464 KB
testcase_09 AC 209 ms
94,744 KB
testcase_10 AC 223 ms
94,592 KB
testcase_11 AC 165 ms
82,432 KB
testcase_12 AC 185 ms
89,904 KB
testcase_13 AC 142 ms
81,736 KB
testcase_14 AC 159 ms
82,312 KB
testcase_15 AC 195 ms
89,004 KB
testcase_16 AC 150 ms
85,000 KB
testcase_17 AC 140 ms
79,520 KB
testcase_18 AC 166 ms
87,332 KB
testcase_19 AC 189 ms
84,824 KB
testcase_20 AC 182 ms
78,476 KB
testcase_21 AC 188 ms
86,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
from collections import defaultdict
def ceil(A,B):
    return -(-A//B)
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(sys.stdin.readline().rstrip())
    def IC(): return [int(c) for c in sys.stdin.readline().rstrip()]
    def MI(): return map(int, sys.stdin.readline().split())
    N,M = MI()
    L = LI()
    L = [-10**10] + L + [10**10]
    from bisect import bisect_left
    S = 0
    for i in range(M):
        F,B,W = MI()
        lake = bisect_left(L,F)
        C = min(abs(L[lake-1]-F),abs(L[lake]-F))
        S += max(B,W-C)
    print(S)
    return
solve()
0