結果
| 問題 | No.871 かえるのうた |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-24 08:42:23 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 736 bytes |
| 記録 | |
| コンパイル時間 | 161 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 48,928 KB |
| 最終ジャッジ日時 | 2024-07-08 07:37:35 |
| 合計ジャッジ時間 | 12,597 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 2 -- * 32 |
コンパイルメッセージ
Main.rb:4: warning: assigned but unused variable - n Main.rb:12: 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)]
@c=0
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.push(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.push(elm)
end
f(elm,1)
f(elm,-1)
end
end
end
@c+=1
end
f(p,1)
f(p,-1)
@t=[0] if @t==nil
p @t.length