結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 21:47:10 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 198 ms / 2,000 ms | 
| コード長 | 463 bytes | 
| コンパイル時間 | 201 ms | 
| コンパイル使用メモリ | 82,724 KB | 
| 実行使用メモリ | 90,448 KB | 
| 最終ジャッジ日時 | 2024-11-18 15:49:15 | 
| 合計ジャッジ時間 | 4,557 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
import bisect def main(): n,m=map(int,input().split()) ls=list(map(int,input().split())) ans = 0 for i in range(m): f,b,w=map(int,input().split()) idx = bisect.bisect(ls,f) cost = 10**10 if idx < n: cost1 = abs(f-ls[idx]) if cost1 < cost: cost = cost1 if 0 <= idx-1: cost2 = abs(f-ls[idx-1]) if cost2 < cost: cost = cost2 if cost < w-b: ans += w - cost else: ans += b print(ans) if __name__ == "__main__": main()
