結果

問題 No.871 かえるのうた
ユーザー wipexwipex
提出日時 2019-11-05 23:24:28
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,266 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 42,192 KB
最終ジャッジ日時 2023-10-13 02:31:39
合計ジャッジ時間 10,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,348 KB
testcase_01 AC 80 ms
15,152 KB
testcase_02 AC 81 ms
15,048 KB
testcase_03 AC 81 ms
15,348 KB
testcase_04 AC 82 ms
15,272 KB
testcase_05 AC 80 ms
15,264 KB
testcase_06 AC 80 ms
15,296 KB
testcase_07 AC 80 ms
15,036 KB
testcase_08 WA -
testcase_09 AC 155 ms
16,040 KB
testcase_10 AC 635 ms
15,160 KB
testcase_11 AC 85 ms
15,360 KB
testcase_12 AC 1,516 ms
17,840 KB
testcase_13 AC 480 ms
15,908 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 109 ms
19,240 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]


update = true
@t=[[nil,0]]
xxx = @x.length

def aaa(elm)
 if @t.any? {|w,y| w == elm }
   return true
 else
   if @t[0][0]==nil
     @t=[[elm,0]]
   else
     @t.push([elm,0])
   end
   return false
 end
end

while(update)
  if @t[0][0]==nil
    b = @hash[p]
    zzz = p+b
    zzz1 = p+(-1*b)
    for i in 0...xxx do
      if zzz1 > zzz
        if @x[i] >=zzz and zzz1 >= @x[i]
          break if aaa(@x[i])==false
        end
      else
        if zzz >= @x[i] and @x[i] >= zzz1
          break if aaa(@x[i])==false
        end
      end
      #break if i == xxx-1
    end
  else
    cnt = 0
    @t.each do |elm, elm2|
      next if elm2==1
      b = @hash[elm]
      zzz = elm+b
      zzz1 = elm+(-1*b)
      @t[cnt][1] = 1 
      for i in 0...xxx do
        update = false if i == xxx-1
        if zzz1 > zzz
          if @x[i] >=zzz and zzz1 >= @x[i]
            aaa(@x[i])
          end
        else
          if zzz >= @x[i] and @x[i] >= zzz1
            aaa(@x[i])
          end
        end
      end
      cnt+=1
    end
  end
end

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