結果

問題 No.1268 Fruit Rush 2
ユーザー simansiman
提出日時 2022-03-03 16:11:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 371 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 11,160 KB
実行使用メモリ 58,468 KB
最終ジャッジ日時 2023-09-24 11:42:48
合計ジャッジ時間 10,483 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,216 KB
testcase_01 AC 81 ms
15,196 KB
testcase_02 AC 78 ms
15,296 KB
testcase_03 AC 76 ms
15,260 KB
testcase_04 AC 78 ms
15,028 KB
testcase_05 AC 75 ms
15,124 KB
testcase_06 AC 76 ms
15,252 KB
testcase_07 AC 75 ms
15,156 KB
testcase_08 AC 77 ms
15,020 KB
testcase_09 AC 75 ms
15,004 KB
testcase_10 AC 79 ms
15,300 KB
testcase_11 AC 76 ms
15,132 KB
testcase_12 AC 75 ms
15,260 KB
testcase_13 AC 72 ms
15,072 KB
testcase_14 AC 74 ms
15,212 KB
testcase_15 AC 76 ms
15,024 KB
testcase_16 AC 271 ms
40,956 KB
testcase_17 AC 242 ms
34,872 KB
testcase_18 AC 259 ms
35,744 KB
testcase_19 AC 249 ms
35,440 KB
testcase_20 AC 255 ms
35,480 KB
testcase_21 AC 255 ms
35,300 KB
testcase_22 AC 295 ms
40,584 KB
testcase_23 AC 302 ms
40,628 KB
testcase_24 AC 263 ms
36,044 KB
testcase_25 AC 261 ms
35,644 KB
testcase_26 AC 254 ms
39,832 KB
testcase_27 AC 259 ms
39,860 KB
testcase_28 AC 264 ms
40,412 KB
testcase_29 AC 262 ms
39,680 KB
testcase_30 AC 261 ms
40,356 KB
testcase_31 AC 371 ms
46,500 KB
testcase_32 AC 352 ms
46,488 KB
testcase_33 AC 349 ms
58,468 KB
testcase_34 AC 304 ms
46,312 KB
testcase_35 AC 335 ms
58,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

ans = 0
mixed = Hash.new(0)

A.each do |a|
  ans += 1

  if C[a - 1]
    mixed[a + 1] += 1
    ans += 1
  end

  if mixed[a - 1] > 0
    mixed[a + 1] += mixed[a - 1]
    ans += mixed[a - 1]
  end
end

puts ans
0