k番目に大きい数(Rubyの場合)
flag = 0 k,n = 0, 0 number = Array.new File.open("../data_d.txt","r"){|f| f.each{|line| if flag == 0 n,k = line.split.collect{|i| i.to_i} flag = 1 elsif flag && number.size < n number << line.to_i end } } p number.sort_by{|i| -i}[k-1]