結果

問題 No.2408 Lakes and Fish
ユーザー moharan627moharan627
提出日時 2023-08-11 21:30:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 92,288 KB
最終ジャッジ日時 2024-04-29 12:19:39
合計ジャッジ時間 4,476 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
53,760 KB
testcase_01 AC 48 ms
53,376 KB
testcase_02 AC 47 ms
53,504 KB
testcase_03 AC 47 ms
53,504 KB
testcase_04 AC 152 ms
92,160 KB
testcase_05 AC 153 ms
92,288 KB
testcase_06 AC 164 ms
92,032 KB
testcase_07 AC 190 ms
91,520 KB
testcase_08 AC 190 ms
91,520 KB
testcase_09 AC 191 ms
91,904 KB
testcase_10 AC 191 ms
91,520 KB
testcase_11 AC 141 ms
80,384 KB
testcase_12 AC 165 ms
88,448 KB
testcase_13 AC 116 ms
78,720 KB
testcase_14 AC 133 ms
81,152 KB
testcase_15 AC 176 ms
86,912 KB
testcase_16 AC 120 ms
82,816 KB
testcase_17 AC 114 ms
77,312 KB
testcase_18 AC 141 ms
85,760 KB
testcase_19 AC 166 ms
82,688 KB
testcase_20 AC 160 ms
76,288 KB
testcase_21 AC 168 ms
84,864 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