結果

問題 No.2408 Lakes and Fish
ユーザー 👑 timitimi
提出日時 2023-08-12 11:55:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 107,136 KB
最終ジャッジ日時 2024-04-30 01:54:46
合計ジャッジ時間 5,696 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,352 KB
testcase_01 AC 44 ms
51,840 KB
testcase_02 AC 42 ms
52,096 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 226 ms
106,240 KB
testcase_05 AC 239 ms
106,368 KB
testcase_06 AC 168 ms
106,752 KB
testcase_07 AC 261 ms
107,136 KB
testcase_08 AC 266 ms
106,624 KB
testcase_09 AC 266 ms
106,624 KB
testcase_10 AC 259 ms
106,752 KB
testcase_11 AC 175 ms
84,352 KB
testcase_12 AC 214 ms
99,840 KB
testcase_13 AC 130 ms
82,560 KB
testcase_14 AC 164 ms
84,608 KB
testcase_15 AC 224 ms
96,640 KB
testcase_16 AC 148 ms
90,368 KB
testcase_17 AC 133 ms
79,360 KB
testcase_18 AC 179 ms
94,336 KB
testcase_19 AC 214 ms
89,984 KB
testcase_20 AC 186 ms
76,800 KB
testcase_21 AC 224 ms
93,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int, input().split())
L=list(map(int, input().split()))
A=L.copy()
A.append(-10**12)
A.append(10**12)
A=sorted(A)
LL=set(L)
import bisect
ans=0
for i in range(M):
  f,b,w=map(int, input().split())
  if f in LL:
    ans+=w 
  else:
    d=bisect.bisect_left(A,f)
    x,y=A[d-1],A[d]
    p=max(b,w-abs(f-x),w-abs(f-y))
    ans+=p
print(ans)
0