結果

問題 No.115 遠足のおやつ
ユーザー simansiman
提出日時 2015-01-13 02:44:58
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 521 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 15,512 KB
最終ジャッジ日時 2023-09-04 05:08:47
合計ジャッジ時間 5,303 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,268 KB
testcase_01 AC 81 ms
15,132 KB
testcase_02 AC 79 ms
15,048 KB
testcase_03 AC 82 ms
15,180 KB
testcase_04 AC 82 ms
15,292 KB
testcase_05 AC 81 ms
15,032 KB
testcase_06 AC 80 ms
14,988 KB
testcase_07 AC 81 ms
15,280 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 82 ms
15,184 KB
testcase_14 AC 81 ms
15,120 KB
testcase_15 AC 81 ms
15,136 KB
testcase_16 AC 80 ms
15,304 KB
testcase_17 AC 81 ms
14,988 KB
testcase_18 WA -
testcase_19 AC 83 ms
15,136 KB
testcase_20 AC 82 ms
15,244 KB
testcase_21 RE -
testcase_22 AC 81 ms
15,236 KB
testcase_23 AC 81 ms
15,244 KB
testcase_24 AC 82 ms
15,028 KB
testcase_25 AC 83 ms
15,244 KB
testcase_26 AC 81 ms
15,240 KB
testcase_27 AC 81 ms
15,268 KB
testcase_28 AC 81 ms
15,096 KB
testcase_29 AC 82 ms
15,208 KB
testcase_30 AC 82 ms
14,988 KB
testcase_31 AC 83 ms
15,244 KB
testcase_32 AC 81 ms
15,076 KB
testcase_33 AC 82 ms
15,228 KB
testcase_34 AC 81 ms
15,128 KB
testcase_35 AC 80 ms
15,100 KB
testcase_36 AC 82 ms
15,048 KB
testcase_37 AC 82 ms
15,104 KB
testcase_38 AC 80 ms
15,092 KB
testcase_39 AC 81 ms
15,104 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 82 ms
15,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:24: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

class A
  def initialize
    n, d, k = gets.chomp.split(' ').map(&:to_i)

    answer = [*(1..k-1)] + [d-(1..k-1).inject(:+)]

    diff = answer.last - n

    if diff > 0
      answer[-1] -= diff

      (k-2).downto(0) do |index|
        sub = [diff, (answer[index+1] - 1) - answer[index]].min
        answer[index] += sub
        diff -= sub

        break if diff.zero?
      end
    end

    if answer.inject(:+) == d and answer.uniq.size == k
      puts answer.join(' ')
    else
      puts -1
    end
  end
end

A.new
0