結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  tomerun | 
| 提出日時 | 2023-08-11 21:26:47 | 
| 言語 | Crystal (1.14.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 67 ms / 2,000 ms | 
| コード長 | 289 bytes | 
| コンパイル時間 | 10,324 ms | 
| コンパイル使用メモリ | 294,544 KB | 
| 実行使用メモリ | 9,600 KB | 
| 最終ジャッジ日時 | 2024-11-18 15:23:57 | 
| 合計ジャッジ時間 | 12,425 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
n, m = read_line.split.map(&.to_i)
l = [-(1 << 30)] + read_line.split.map(&.to_i) + [1 << 30]
ans = 0i64
m.times do
  f, b, w = read_line.split.map(&.to_i)
  pos = l.bsearch_index { |x, i| x >= f }.not_nil!
  dist = {l[pos] - f, f - l[pos - 1]}.min
  ans += {b, w - dist}.max
end
puts ans
            
            
            
        