結果
| 問題 | 
                            No.871 かえるのうた
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-10-26 23:59:54 | 
| 言語 | Ruby  (3.4.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 725 bytes | 
| コンパイル時間 | 76 ms | 
| コンパイル使用メモリ | 7,424 KB | 
| 実行使用メモリ | 47,232 KB | 
| 最終ジャッジ日時 | 2024-09-14 20:58:06 | 
| 合計ジャッジ時間 | 11,656 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 TLE * 2 -- * 32 | 
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - n Main.rb:8: 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)]
p=@x[k-1]
b=a[k-1]
def f(p,w)
  b = @hash[p]
  zzz = p+w*b
  zzz1 = p+(-1*w*b)
  @x.each do |elm|
    if zzz1 > zzz
      if elm >=zzz and zzz1 >= elm
        if @t.any? {|w| w == elm }
          next
        else
          @t<<elm
        end
        f(elm,1)
        f(elm,-1)
      end
    else
      if zzz >= elm and elm >= zzz1
        if @t.any? {|w| w == elm }
          next
        else
          @t<<elm
        end
        f(elm,1)
        f(elm,-1)
      end
    end
  end
end
f(p,1)
f(p,-1)
if @t==nil
  p "1"
else
  p @t.length
end