結果
| 問題 |
No.660 家を通り過ぎないランダムウォーク問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-02 23:34:44 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 391 bytes |
| コンパイル時間 | 405 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 22,304 KB |
| 最終ジャッジ日時 | 2024-06-22 12:17:23 |
| 合計ジャッジ時間 | 11,962 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 6 TLE * 2 -- * 17 |
コンパイルメッセージ
Syntax OK
ソースコード
def f(n)
m = 2 * n
ans = 0
xs={}
xs[0]=1
m.times do
ys = {}
xs.keys.each do |x|
if ys[x-1] == nil
ys[x-1] = xs[x]
else
ys[x-1] += xs[x]
end
if ys[x+1] == nil
ys[x+1] = xs[x]
else
ys[x+1] += xs[x]
end
end
ans += ys[n] if ys[n] != nil
xs = ys.clone
xs[n] = 0
end
ans
end
p f(gets.to_i)