結果

問題 No.112 ややこしい鶴亀算
ユーザー norioc
提出日時 2015-11-21 14:55:08
言語 Ruby
(3.4.1)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 315 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-09-13 17:05:59
合計ジャッジ時間 3,093 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def calc(xs)
  if xs.all? {|e| e == xs[0] }
    if xs[0] == 2 * (xs.size - 1)
      return [xs.size, 0]
    else
      return [0, xs.size]
    end
  end

  crane = xs.count(xs.max)
  turtle = xs.size - crane
  [crane, turtle]
end

gets # read n
xs = gets.split.map(&:to_i)
ans = calc(xs)
puts "#{ans[0]} #{ans[1]}"
0