結果

問題 No.59 鉄道の旅
ユーザー letrangerjpletrangerjp
提出日時 2017-06-17 21:41:38
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 18,176 KB
最終ジャッジ日時 2024-04-08 20:36:01
合計ジャッジ時間 4,300 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
16,256 KB
testcase_01 AC 82 ms
16,256 KB
testcase_02 AC 85 ms
16,256 KB
testcase_03 AC 81 ms
16,256 KB
testcase_04 WA -
testcase_05 AC 85 ms
16,256 KB
testcase_06 WA -
testcase_07 AC 80 ms
16,256 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 94 ms
16,384 KB
testcase_12 AC 209 ms
17,408 KB
testcase_13 AC 478 ms
17,792 KB
testcase_14 AC 1,086 ms
18,176 KB
testcase_15 AC 83 ms
16,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.take(2).map(&:to_i)
WA = N.times.map{ gets.to_i }

cargo = []
WA.each{|w|
  if w > 0
    idx = cargo.bsearch_index{|v|v >= w}
    over_w = idx ? cargo.size - idx : 0
    if over_w < K
      cargo[idx || cargo.size, 0] = w
    end
    # p "a" if cargo.sort != cargo
  else
    idx = cargo.bsearch_index{|v|v == -w}
    cargo.delete_at(idx) if idx
  end
}
p cargo.size
0