結果
問題 | No.871 かえるのうた |
ユーザー |
|
提出日時 | 2019-10-20 23:34:34 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 693 bytes |
コンパイル時間 | 108 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 47,616 KB |
最終ジャッジ日時 | 2024-07-02 17:34:20 |
合計ジャッジ時間 | 8,710 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 7 TLE * 1 -- * 32 |
コンパイルメッセージ
Main.rb:4: warning: assigned but unused variable - n Main.rb:12: warning: assigned but unused variable - b Syntax OK
ソースコード
@x=[] a=[] @t=[] n,k = gets.chomp.split(" ").map(&:to_i) @x+=gets.chomp.split(" ").map(&:to_i) a+=gets.chomp.split(" ").map(&:to_i) @hash = Hash[*([@x,a].transpose.flatten)] @c=0 p=@x[k-1] b=a[k-1] def f(p,w) b = @hash[p] zzz = p+w*b @x.each do |elm| if w == -1 if elm >= zzz and p > elm if @t.any? {|w| w == elm } return else @t.push(elm) end f(elm,1) f(elm,-1) end else if zzz >= elm and elm > p if @t.any? {|w| w == elm } return else @t.push(elm) end f(elm,1) f(elm,-1) end end end @c+=1 end f(p,1) f(p,-1) p @t.length