結果

問題 No.1438 Broken Drawers
ユーザー simansiman
提出日時 2021-03-29 13:40:03
言語 Ruby
(3.3.0)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 48,024 KB
最終ジャッジ日時 2023-08-19 16:07:38
合計ジャッジ時間 8,743 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,144 KB
testcase_01 AC 76 ms
15,168 KB
testcase_02 AC 77 ms
15,032 KB
testcase_03 AC 76 ms
15,176 KB
testcase_04 AC 77 ms
15,124 KB
testcase_05 AC 77 ms
15,312 KB
testcase_06 AC 293 ms
47,336 KB
testcase_07 AC 282 ms
47,492 KB
testcase_08 AC 77 ms
15,316 KB
testcase_09 AC 76 ms
15,076 KB
testcase_10 AC 77 ms
15,172 KB
testcase_11 AC 86 ms
16,448 KB
testcase_12 AC 163 ms
28,392 KB
testcase_13 AC 217 ms
34,124 KB
testcase_14 AC 133 ms
23,052 KB
testcase_15 AC 313 ms
45,984 KB
testcase_16 AC 310 ms
45,596 KB
testcase_17 AC 322 ms
46,264 KB
testcase_18 AC 323 ms
46,536 KB
testcase_19 AC 329 ms
46,812 KB
testcase_20 AC 331 ms
46,912 KB
testcase_21 AC 323 ms
46,660 KB
testcase_22 AC 338 ms
47,072 KB
testcase_23 AC 338 ms
47,868 KB
testcase_24 AC 340 ms
47,504 KB
testcase_25 AC 339 ms
48,024 KB
testcase_26 AC 339 ms
47,352 KB
testcase_27 AC 339 ms
47,572 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

A.each_with_index do |a, i|
  pos[a] = i
end

checked = Hash.new(false)
ans = 0

A.sort.each do |a|
  idx = pos[a]
  next if checked[idx]

  checked[idx] = true
  checked[idx - 1] = true
  ans += 1
end

puts ans
0