結果

問題 No.871 かえるのうた
ユーザー wipex
提出日時 2019-10-30 22:03:13
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 33,760 KB
最終ジャッジ日時 2024-09-14 21:58:33
合計ジャッジ時間 6,399 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 11 TLE * 1 -- * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

@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]

def aaa(elm)
 if @t.any? {|w| w == elm }
   return true
 else
   @t.push(elm)
 end
end

update = true
while(update)
  b = @hash[p]
  zzz = p+b
  zzz1 = p+(-1*b)
  @x.each do |elm|
    if zzz1 > zzz
      if elm >=zzz and zzz1 >= elm
        next if aaa(elm)== true
        p = elm
        break
      elsif @x.last == elm
        update = false
      end

    else
      if zzz >= elm and elm >= zzz1
        next if aaa(elm)== true
        p = elm
        break
      elsif @x.last == elm
        update = false
      end
    end
  end
end

if @t==nil
 p "1"
else
 p @t.length
end
0