結果

問題 No.2559 眩しい数直線
ユーザー ngng628ngng628
提出日時 2023-12-02 14:43:17
言語 Crystal
(1.11.2)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 16,276 ms
コンパイル使用メモリ 292,988 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 14:43:35
合計ジャッジ時間 15,240 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 7 ms
6,676 KB
testcase_04 AC 7 ms
6,676 KB
testcase_05 AC 11 ms
6,676 KB
testcase_06 AC 25 ms
6,676 KB
testcase_07 AC 24 ms
6,676 KB
testcase_08 AC 28 ms
6,676 KB
testcase_09 AC 16 ms
6,676 KB
testcase_10 AC 12 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 AC 19 ms
6,676 KB
testcase_14 AC 23 ms
6,676 KB
testcase_15 AC 26 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 23 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 19 ms
6,676 KB
testcase_20 AC 15 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 17 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x = read_line.split.map &.to_i64
ab = (1..n).map { a, b = read_line.split.map &.to_i64; {a, b} }

hash = Hash(Int64, Int64).new(0_i64)
ab.each do |(ai, bi)|
  now = bi
  (0..).each do |j|
    hash[ai + j] = Math.max(hash[ai + j], now)
    hash[ai - j] = Math.max(hash[ai - j], now)
    now -= 1
    break if now == 0
  end
end

puts (1..x).map { |i| hash[i]? || 0 }.join(' ')
0