結果

問題 No.871 かえるのうた
ユーザー wipexwipex
提出日時 2019-10-20 23:34:34
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 41,736 KB
最終ジャッジ日時 2023-09-15 14:47:41
合計ジャッジ時間 9,895 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 77 ms
15,228 KB
testcase_02 AC 75 ms
15,096 KB
testcase_03 WA -
testcase_04 AC 76 ms
15,156 KB
testcase_05 AC 75 ms
15,088 KB
testcase_06 AC 75 ms
15,116 KB
testcase_07 AC 75 ms
15,020 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 149 ms
15,828 KB
testcase_11 AC 79 ms
15,480 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 TLE -
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:4: warning: assigned but unused variable - n
Main.rb:12: warning: assigned but unused variable - b
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)]

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