結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 83 ms
14,988 KB
testcase_03 WA -
testcase_04 AC 83 ms
15,188 KB
testcase_05 AC 82 ms
15,052 KB
testcase_06 WA -
testcase_07 AC 87 ms
15,244 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 84 ms
15,028 KB
testcase_15 AC 84 ms
15,096 KB
testcase_16 AC 85 ms
15,192 KB
testcase_17 AC 84 ms
15,096 KB
testcase_18 WA -
testcase_19 AC 85 ms
15,176 KB
testcase_20 AC 86 ms
15,096 KB
testcase_21 RE -
testcase_22 AC 82 ms
15,128 KB
testcase_23 WA -
testcase_24 AC 84 ms
15,268 KB
testcase_25 AC 85 ms
15,108 KB
testcase_26 AC 85 ms
15,056 KB
testcase_27 AC 89 ms
15,276 KB
testcase_28 AC 85 ms
15,076 KB
testcase_29 AC 85 ms
15,236 KB
testcase_30 AC 84 ms
15,272 KB
testcase_31 AC 85 ms
15,076 KB
testcase_32 AC 86 ms
15,300 KB
testcase_33 AC 84 ms
15,100 KB
testcase_34 AC 84 ms
15,204 KB
testcase_35 AC 85 ms
15,100 KB
testcase_36 AC 84 ms
14,984 KB
testcase_37 AC 85 ms
15,144 KB
testcase_38 AC 85 ms
15,024 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 90 ms
15,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:25: 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 answer.join(' ')
      puts -1
    end
  end
end

A.new
0