結果

問題 No.2408 Lakes and Fish
ユーザー tomeruntomerun
提出日時 2023-08-11 21:26:47
言語 Crystal
(1.11.2)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 15,877 ms
コンパイル使用メモリ 295,300 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-04-29 12:15:39
合計ジャッジ時間 13,336 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 57 ms
9,472 KB
testcase_05 AC 57 ms
9,472 KB
testcase_06 AC 58 ms
9,600 KB
testcase_07 AC 70 ms
9,600 KB
testcase_08 AC 70 ms
9,472 KB
testcase_09 AC 70 ms
9,472 KB
testcase_10 AC 71 ms
9,344 KB
testcase_11 AC 41 ms
6,016 KB
testcase_12 AC 50 ms
9,472 KB
testcase_13 AC 16 ms
5,376 KB
testcase_14 AC 33 ms
6,016 KB
testcase_15 AC 57 ms
9,472 KB
testcase_16 AC 19 ms
6,144 KB
testcase_17 AC 20 ms
5,376 KB
testcase_18 AC 36 ms
9,344 KB
testcase_19 AC 56 ms
7,680 KB
testcase_20 AC 55 ms
5,376 KB
testcase_21 AC 56 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0