結果
問題 | No.320 眠れない夜に |
ユーザー |
|
提出日時 | 2016-04-05 20:12:57 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 418 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-10-04 01:58:06 |
合計ジャッジ時間 | 4,818 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
コンパイルメッセージ
Main.rb:10: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:27: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
n,m = gets.split.map(&:to_i)dp = Array.new(n + 1)dp[0] = 0dp[1] = 12.upto(n){|i|dp[i] = dp[i - 1] + dp[i - 2]}x = dp[n] - mif x < 0p -1elsif x == 0p 0elseans = 0(n - 2).downto(1){|i|if x >= dp[i]x -= dp[i]ans += 1endif x == 0breakend}if x == 0p anselsep -1endend