結果

問題 No.930 数列圧縮
ユーザー simansiman
提出日時 2022-02-15 02:38:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 11,292 KB
実行使用メモリ 25,756 KB
最終ジャッジ日時 2023-09-11 16:53:23
合計ジャッジ時間 7,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,324 KB
testcase_01 AC 81 ms
15,152 KB
testcase_02 AC 81 ms
15,328 KB
testcase_03 AC 83 ms
15,292 KB
testcase_04 AC 81 ms
15,128 KB
testcase_05 AC 84 ms
15,372 KB
testcase_06 AC 82 ms
15,168 KB
testcase_07 AC 85 ms
15,332 KB
testcase_08 AC 151 ms
21,108 KB
testcase_09 AC 156 ms
21,216 KB
testcase_10 AC 143 ms
21,028 KB
testcase_11 AC 153 ms
21,188 KB
testcase_12 AC 161 ms
21,292 KB
testcase_13 AC 104 ms
18,300 KB
testcase_14 AC 106 ms
19,120 KB
testcase_15 AC 181 ms
25,676 KB
testcase_16 AC 181 ms
25,492 KB
testcase_17 AC 181 ms
25,328 KB
testcase_18 AC 177 ms
25,756 KB
testcase_19 AC 179 ms
25,500 KB
testcase_20 AC 181 ms
25,668 KB
testcase_21 AC 184 ms
25,580 KB
testcase_22 AC 82 ms
15,040 KB
testcase_23 AC 184 ms
25,584 KB
testcase_24 AC 84 ms
15,076 KB
testcase_25 AC 82 ms
15,220 KB
testcase_26 AC 82 ms
15,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

ans = []
stack = []

A.reverse_each do |a|
  if A[0] <= a
    stack << a
  else
    if stack.empty?
      puts 'No'
      exit
    else
      ans << a
    end
  end
end

stack.pop

until stack.empty?
  v = stack.pop
  ans << v
end

puts 'Yes'
puts ans.join(' ')
0