結果

問題 No.59 鉄道の旅
ユーザー gigurururugigurururu
提出日時 2014-11-07 00:14:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,120 ms / 5,000 ms
コード長 290 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 16,132 KB
最終ジャッジ日時 2023-08-26 05:27:35
合計ジャッジ時間 4,428 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,076 KB
testcase_01 AC 79 ms
15,308 KB
testcase_02 AC 79 ms
15,168 KB
testcase_03 AC 81 ms
15,292 KB
testcase_04 AC 354 ms
15,812 KB
testcase_05 AC 79 ms
15,060 KB
testcase_06 AC 82 ms
15,316 KB
testcase_07 AC 81 ms
15,120 KB
testcase_08 AC 100 ms
15,324 KB
testcase_09 AC 98 ms
15,364 KB
testcase_10 AC 99 ms
15,264 KB
testcase_11 AC 95 ms
15,488 KB
testcase_12 AC 225 ms
15,240 KB
testcase_13 AC 496 ms
15,728 KB
testcase_14 AC 1,120 ms
16,132 KB
testcase_15 AC 80 ms
15,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,k=gets.split.map &:to_i
l=[]
n.times{
  w=gets.to_i
  if w<0
    i=(0..l.size-1).bsearch{|x|l[x]>=-w}||l.size
    if l[i]==-w
      l.delete_at(i)
    end
  else
    i=(0..l.size-1).bsearch{|x|l[x]>=w}||l.size
    if l.size-i<k
      l.insert(i,w)
    end
  end
}
p l.size
0