結果

問題 No.115 遠足のおやつ
ユーザー gigurururu
提出日時 2014-12-29 00:29:16
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 301 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-06-13 00:05:39
合計ジャッジ時間 4,321 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n,d,k=gets.split.map(&:to_i)
summin=k*(k+1)/2
summax=summin+(n-k)*k
if summin>d||summax<d||k>n
  p -1
else
  if d==summin
    puts [*1..n]*" "
  elsif d==summax
    puts [*n-k..n]*" "
  else
    diff=d-summin
    puts [*1..k-(m=diff/(n-k))-1,k-m+(diff-m*(n-k)),*(k-m+1..k).map{|i|i+n-k}]*" "
  end
end
0