結果

問題 No.871 かえるのうた
ユーザー wipexwipex
提出日時 2019-11-04 09:21:20
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,772 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 11,488 KB
実行使用メモリ 42,128 KB
最終ジャッジ日時 2023-10-13 01:53:01
合計ジャッジ時間 7,394 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
19,412 KB
testcase_01 AC 81 ms
15,248 KB
testcase_02 AC 82 ms
15,104 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 83 ms
15,060 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 86 ms
15,364 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 114 ms
19,216 KB
testcase_19 RE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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<<elm
   return false
 end
end

update = true
while(update)
  b = @hash[p]
  zzz = p+b
  zzz1 = p+(-1*b)
  xxx = @x.length
  for i in 0...xxx do
    if zzz1 > zzz
      if @x[i] >=zzz and zzz1 >= @x[i]
        if aaa(@x[i])== true
          if i == xxx-1
            update = false
          else
            next
          end
        else
          p = @x[i]
        end
      elsif i == xxx-1
        update = false
      end
    else
      if zzz >= @x[i].to_i and @x[i].to_i >= zzz1
        if aaa(@x[i])== true
          if i == xxx-1
            update = false
          else
            next
          end
        else
          p = @x[i]
        end
      elsif i == xxx-1
        update = false
      end
    end
  end
end

pp=@x[k-1]
#@t.compact!
@y = @x.reverse

update = true
while(update)
  c = @hash[pp]
  zzz = pp+c
  zzz1 = pp+(-1*c)
  yyy = @y.length
  for i in 0...yyy do
    if zzz1 > zzz
      if @y[i] >=zzz and zzz1 >= @y[i]
        if aaa(@y[i])== true
          if i== yyy-1
            update = false
          else
            next
          end
        else
          pp = @y[i]
        end
      elsif i == yyy-1
        update = false
      end
    else
      if zzz >= @y[i].to_i and @y[i].to_i >= zzz1
        if aaa(@y[i])== true
          if i== yyy-1
            update = false
          else
            next
          end
        else
          pp = @y[i]
        end
      elsif i == yyy-1
        update = false
      end
    end
  end
end

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