結果

問題 No.115 遠足のおやつ
コンテスト
ユーザー gigurururu
提出日時 2014-12-29 00:30:02
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 303 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 299 ms
コンパイル使用メモリ 8,960 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2026-05-17 23:59:19
合計ジャッジ時間 4,442 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: ambiguous first argument; put parentheses or a space even after `-` operator
Syntax OK

ソースコード

diff #
raw source code

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+1..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