結果

問題 No.2126 MEX Game
ユーザー simansiman
提出日時 2022-11-20 07:37:21
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 379 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 35,940 KB
最終ジャッジ日時 2023-10-21 08:36:33
合計ジャッジ時間 5,471 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
16,092 KB
testcase_01 AC 88 ms
16,092 KB
testcase_02 AC 87 ms
16,088 KB
testcase_03 AC 87 ms
16,092 KB
testcase_04 AC 87 ms
16,092 KB
testcase_05 AC 85 ms
16,092 KB
testcase_06 AC 86 ms
16,092 KB
testcase_07 WA -
testcase_08 AC 87 ms
16,092 KB
testcase_09 AC 85 ms
16,092 KB
testcase_10 AC 168 ms
28,144 KB
testcase_11 AC 176 ms
28,144 KB
testcase_12 AC 178 ms
29,756 KB
testcase_13 AC 179 ms
29,756 KB
testcase_14 AC 183 ms
30,792 KB
testcase_15 AC 177 ms
30,792 KB
testcase_16 AC 179 ms
30,092 KB
testcase_17 AC 162 ms
23,704 KB
testcase_18 AC 161 ms
24,028 KB
testcase_19 AC 148 ms
23,600 KB
testcase_20 AC 147 ms
23,600 KB
testcase_21 AC 188 ms
35,940 KB
testcase_22 AC 87 ms
16,092 KB
testcase_23 AC 87 ms
16,092 KB
testcase_24 AC 88 ms
16,092 KB
testcase_25 AC 87 ms
16,092 KB
testcase_26 WA -
testcase_27 AC 88 ms
16,092 KB
testcase_28 AC 86 ms
16,088 KB
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:6: warning: assigned but unused variable - ans
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i).sort
C = A.tally
C.default = 0

ans = 0

def f(nums)
  c = nums.tally
  c.default = 0
  m = nums.max

  0.upto(m) do |x|
    return [false, x] if c[x] <= 1
  end

  [true, m + 1]
end

res, v = f(A)

if res
  puts v
else
  idx = A.rindex { |a| a > v }

  if idx.nil?
    puts v
  else
    A[idx] = v

    _, v = f(A)

    puts v
  end
end
0