結果
| 問題 |
No.1686 Geschenkt
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-24 03:09:10 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 284 bytes |
| コンパイル時間 | 54 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-10-01 11:50:51 |
| 合計ジャッジ時間 | 1,384 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 2 |
コンパイルメッセージ
Syntax OK
ソースコード
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