結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2018-03-28 09:54:43 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 91 ms / 5,000 ms |
コード長 | 436 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 8,064 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2025-01-03 01:27:53 |
合計ジャッジ時間 | 5,117 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
コンパイルメッセージ
Main.rb:11: warning: ambiguous first argument; put parentheses or a space even after `-` operator Main.rb:41: warning: ambiguous first argument; put parentheses or a space even after `-` operator Syntax OK
ソースコード
n,d,k=gets.split.map{|e| e.to_i} x=[] sum=0 k.times{|i| x<<i+1 sum+=(i+1) } if d<sum || n<k puts -1 elsif d==sum puts x*" " else k.times{|i| p1=k-i-1 while true if sum==d break end if p1==k-1 if x[p1]==n break end else if x[p1]+1==x[p1+1] break end end sum+=1 x[p1]+=1 if sum==d break end end break if sum==d } if sum==d puts x*" " else puts -1 end end