結果

問題 No.91 赤、緑、青の石
ユーザー simansiman
提出日時 2015-04-02 20:09:53
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 783 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-09-06 12:10:09
合計ジャッジ時間 3,787 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,340 KB
testcase_01 AC 84 ms
15,168 KB
testcase_02 AC 82 ms
15,104 KB
testcase_03 AC 84 ms
15,156 KB
testcase_04 AC 81 ms
15,344 KB
testcase_05 AC 83 ms
15,112 KB
testcase_06 AC 80 ms
15,160 KB
testcase_07 AC 76 ms
15,240 KB
testcase_08 AC 73 ms
15,232 KB
testcase_09 AC 76 ms
15,076 KB
testcase_10 AC 75 ms
15,148 KB
testcase_11 AC 74 ms
15,156 KB
testcase_12 AC 71 ms
15,060 KB
testcase_13 AC 75 ms
15,068 KB
testcase_14 AC 75 ms
15,176 KB
testcase_15 AC 74 ms
15,036 KB
testcase_16 AC 75 ms
15,304 KB
testcase_17 AC 75 ms
15,168 KB
testcase_18 AC 78 ms
15,088 KB
testcase_19 AC 73 ms
15,108 KB
testcase_20 AC 76 ms
15,088 KB
testcase_21 AC 69 ms
15,104 KB
testcase_22 AC 73 ms
15,160 KB
testcase_23 AC 75 ms
15,288 KB
testcase_24 AC 79 ms
15,320 KB
testcase_25 AC 75 ms
15,280 KB
testcase_26 AC 76 ms
15,200 KB
testcase_27 AC 76 ms
15,232 KB
testcase_28 AC 75 ms
15,200 KB
testcase_29 AC 71 ms
15,076 KB
testcase_30 AC 74 ms
15,032 KB
testcase_31 AC 73 ms
15,172 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  attr_reader :red, :green, :blue

  def initialize
    @red, @green, @blue = gets.chomp.split(' ').map(&:to_i)

    min_count = 0
    max_count = 10000000
    create_count = 0

    while min_count < max_count
      create_count = (min_count + max_count) / 2

      if can_create?(create_count)
        min_count = create_count + 1
      else
        max_count = create_count
      end
    end

    puts min_count - 1
  end

  def can_create?(count)
    rest_count = 0
    rest_count += [0, red - count].max / 2
    rest_count += [0, green - count].max / 2
    rest_count += [0, blue - count].max / 2

    rest_count -= [0, count - red].max
    rest_count -= [0, count - green].max
    rest_count -= [0, count - blue].max

    rest_count >= 0
  end
end

Yukicoder.new
0