結果

問題 No.115 遠足のおやつ
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-02-27 10:41:43
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 336 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-21 16:49:08
合計ジャッジ時間 4,906 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
12,288 KB
testcase_01 WA -
testcase_02 AC 77 ms
12,288 KB
testcase_03 AC 74 ms
12,160 KB
testcase_04 AC 74 ms
12,288 KB
testcase_05 AC 76 ms
12,288 KB
testcase_06 AC 75 ms
12,288 KB
testcase_07 AC 76 ms
12,160 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 76 ms
12,288 KB
testcase_14 AC 75 ms
12,160 KB
testcase_15 AC 76 ms
12,288 KB
testcase_16 AC 76 ms
12,160 KB
testcase_17 AC 75 ms
12,288 KB
testcase_18 AC 76 ms
12,160 KB
testcase_19 AC 78 ms
12,288 KB
testcase_20 AC 76 ms
12,160 KB
testcase_21 AC 77 ms
12,160 KB
testcase_22 AC 80 ms
12,160 KB
testcase_23 WA -
testcase_24 AC 77 ms
12,032 KB
testcase_25 AC 74 ms
12,160 KB
testcase_26 AC 73 ms
12,288 KB
testcase_27 AC 76 ms
12,032 KB
testcase_28 AC 78 ms
12,160 KB
testcase_29 AC 76 ms
12,160 KB
testcase_30 AC 77 ms
12,288 KB
testcase_31 AC 75 ms
12,288 KB
testcase_32 AC 74 ms
12,160 KB
testcase_33 AC 81 ms
12,288 KB
testcase_34 AC 76 ms
12,288 KB
testcase_35 AC 74 ms
12,160 KB
testcase_36 AC 75 ms
12,160 KB
testcase_37 AC 76 ms
12,160 KB
testcase_38 AC 75 ms
12,160 KB
testcase_39 WA -
testcase_40 AC 74 ms
12,288 KB
testcase_41 AC 78 ms
12,288 KB
testcase_42 AC 75 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def min(a,b); a < b ? a : b; end
N, D, K = gets.split.map(&:to_i)

if K > N
  puts -1
  exit
end

ANS = Array.new(K){|i| K - i }
K.times.inject(D) do |d, i|
  r = K - i
  sum = r * (r + 1) / 2
  if sum > d
    ANS.clear
    ANS << -1
    break
  else
    ANS[i] += min(d - sum, N - K)
    d - ANS[i]
  end
end
puts ANS.reverse.join(' ')
0