結果

問題 No.1686 Geschenkt
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2022-07-02 18:41:04
言語 Ruby
(3.2.2)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 169 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 11,404 KB
実行使用メモリ 15,260 KB
最終ジャッジ日時 2023-08-18 10:20:22
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,228 KB
testcase_01 AC 76 ms
15,260 KB
testcase_02 AC 78 ms
15,064 KB
testcase_03 AC 75 ms
15,260 KB
testcase_04 AC 77 ms
15,068 KB
testcase_05 AC 75 ms
15,208 KB
testcase_06 AC 74 ms
15,192 KB
testcase_07 AC 77 ms
15,132 KB
testcase_08 AC 76 ms
15,096 KB
testcase_09 AC 73 ms
15,212 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split(" ").map(&:to_i).sort!

ans = 0
a.each.with_index{|v, i|
	if i == 0
		ans += v
	else
		if a[i-1] + 1 != v
			ans += v
		end
	end
}
puts ans
0