結果

問題 No.1041 直線大学
ユーザー shi-mo
提出日時 2020-09-29 20:10:51
言語 Ruby
(3.4.1)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-11-16 08:09:06
合計ジャッジ時間 5,149 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
pos = []
n.times{ pos << gets.split.map(&:to_i) }
DELTA = 10**(-8)

result = 0
n.times do |i|
  (i+1).upto(n-1) do |j|
    x1, y1 = pos[i]
    x2, y2 = pos[j]
    if x1 == x2
      result = [result, pos.select{|p| x1 == p[0]}.size].max
      next
    end
    t = 2
    (j+1).upto(n-1) do |k|
      x, y = pos[k]
      dx2 = x2 - x1
      dy2 = y2 - y1
      dx = x - x1
      dy = y - y1
      if (dy2.to_f / dx2 * dx - dy).abs < DELTA
        t += 1
      end
    end
    result = [result, t].max
  end
end
puts result
0