結果

問題 No.2126 MEX Game
ユーザー simansiman
提出日時 2022-11-20 07:16:54
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 27,456 KB
最終ジャッジ日時 2023-10-21 08:21:58
合計ジャッジ時間 5,268 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,104 KB
testcase_01 AC 85 ms
16,104 KB
testcase_02 AC 85 ms
16,104 KB
testcase_03 AC 84 ms
16,104 KB
testcase_04 AC 86 ms
16,104 KB
testcase_05 AC 84 ms
16,104 KB
testcase_06 AC 84 ms
16,104 KB
testcase_07 AC 85 ms
16,104 KB
testcase_08 AC 85 ms
16,104 KB
testcase_09 AC 84 ms
16,104 KB
testcase_10 AC 151 ms
24,964 KB
testcase_11 AC 151 ms
24,964 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 140 ms
24,972 KB
testcase_15 AC 141 ms
24,972 KB
testcase_16 AC 140 ms
24,864 KB
testcase_17 AC 135 ms
22,344 KB
testcase_18 AC 134 ms
22,496 KB
testcase_19 AC 130 ms
22,188 KB
testcase_20 AC 129 ms
22,188 KB
testcase_21 AC 144 ms
27,456 KB
testcase_22 AC 86 ms
16,104 KB
testcase_23 AC 86 ms
16,104 KB
testcase_24 AC 85 ms
16,104 KB
testcase_25 AC 85 ms
16,104 KB
testcase_26 AC 86 ms
16,104 KB
testcase_27 AC 86 ms
16,104 KB
testcase_28 AC 86 ms
16,104 KB
testcase_29 AC 87 ms
16,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

ans = 0
has_three = false

0.upto(A.max) do |a|
  has_three = true if C[a] >= 3

  if C[a] <= 1
    if C[a] == 1
      if has_three
        ans += 1
      elsif (a + 1..A.max).any? { |x| C[x] >= 1 }
        ans += 1
      end
    end

    break
  end

  ans += 1
end

puts ans
0