結果

問題 No.1686 Geschenkt
ユーザー Len
提出日時 2021-10-24 03:12:11
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 284 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-10-01 11:50:58
合計ジャッジ時間 1,406 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i # 持っているカードの枚数
inputs = gets.split(' ').map(&:to_i)

sorted = inputs.sort
total = 0

0.upto(n - 1).each do |i|
  break if i + 1 == n

  total += sorted[i] if i.zero?
  next if sorted[i + 1] - sorted[i] == 1

  total += sorted[i + 1]
end

puts total
0