結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
|
提出日時 | 2023-10-19 00:12:54 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 565 ms / 2,000 ms |
コード長 | 1,091 bytes |
コンパイル時間 | 107 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-09-18 20:11:12 |
合計ジャッジ時間 | 2,640 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
input_line = gets.chomp!.to_iquestions = []for i in 1..input_lineinput_line2 = gets.chomp!.split(' ').map{|n| n.to_i}questions.push(input_line2)endquestions.each do |input_line2|good_points = []for i in 0..input_line2[0]point = []point.push(i)point.push(input_line2[0] - i)good_points.push(point)point2 = point.duppoint2[0] = point2[0] * -1if (!good_points.include?(point2)) thengood_points.push(point2)endpoint3 = point2.duppoint3[1] = point3[1] * -1if (!good_points.include?(point3)) thengood_points.push(point3)endpoint4 = point3.duppoint4[0] = point4[0] * -1if (!good_points.include?(point4)) thengood_points.push(point4)endenddistances = []good_points.each do |point|distance = Math.sqrt((point[0] - 0)**2 + (point[1] - 0)**2)distances.push(distance)endif (distances.length < input_line2[1]) thenputs 'No'elseputs 'Yes'serach = distances.sort[input_line2[1] - 1]index = distances.index(serach)target_point = good_points[index]puts target_point.join(' ')endend