結果

問題 No.2210 equence Squence Seuence
ユーザー simansiman
提出日時 2023-02-12 07:59:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 11,244 KB
実行使用メモリ 33,444 KB
最終ジャッジ日時 2023-09-23 01:27:12
合計ジャッジ時間 7,582 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,144 KB
testcase_01 AC 80 ms
15,120 KB
testcase_02 AC 81 ms
15,256 KB
testcase_03 AC 140 ms
19,928 KB
testcase_04 AC 145 ms
20,240 KB
testcase_05 AC 182 ms
20,348 KB
testcase_06 AC 166 ms
20,828 KB
testcase_07 AC 295 ms
31,592 KB
testcase_08 AC 82 ms
14,980 KB
testcase_09 AC 84 ms
15,220 KB
testcase_10 AC 82 ms
15,316 KB
testcase_11 AC 81 ms
15,004 KB
testcase_12 AC 81 ms
15,284 KB
testcase_13 AC 344 ms
33,444 KB
testcase_14 AC 344 ms
33,420 KB
testcase_15 AC 341 ms
33,240 KB
testcase_16 AC 341 ms
33,364 KB
testcase_17 AC 342 ms
33,412 KB
testcase_18 AC 81 ms
15,236 KB
testcase_19 AC 82 ms
15,312 KB
testcase_20 AC 79 ms
15,316 KB
testcase_21 AC 79 ms
15,332 KB
testcase_22 AC 80 ms
15,148 KB
testcase_23 AC 291 ms
31,600 KB
testcase_24 AC 239 ms
25,836 KB
testcase_25 AC 265 ms
29,392 KB
testcase_26 AC 327 ms
32,340 KB
testcase_27 AC 150 ms
20,596 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

k = 0
idx = nil
same_cnt = 1

A.each_cons(2).with_index do |(a, na), i|
  if a > na
    k += same_cnt

    if k >= K
      idx ||= i
    end
  end

  if a == na
    same_cnt += 1
  else
    same_cnt = 1
  end
end

k += 1
if k == K
  idx = N - 1
end

A.reverse.each_cons(2).with_index do |(a, na), i|
  if a >= na
    k += 1

    if k == K
      idx = (N - 2) - i
    end
  end
end

A.delete_at(idx)

puts A.join(' ')
0