結果
問題 | No.1041 直線大学 |
ユーザー |
![]() |
提出日時 | 2020-05-02 08:36:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 94 ms / 2,000 ms |
コード長 | 748 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-16 07:59:20 |
合計ジャッジ時間 | 2,853 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
def main(): n = int(input()) c = [list(map(int, input().split())) for _ in range(n)] ans = solve(n, c) print(ans) def solve(n, c): ans = 0 for i in range(n): for j in range(i): x1, y1 = c[i] x2, y2 = c[j] if x2 -x1 == 0: ans = max(ans,line(c, x1)) else: a = (y2 - y1)/(x2 - x1) t = y1 - a * x1 ans = max(ans, linear(c, a, t)) return ans def linear(c, a, t): ans = 0 for (x, y) in c: if y == a * x + t: ans += 1 return ans def line(c, a): ans = 0 for (x, y) in c: if a == x: ans += 1 return ans if __name__ == '__main__': main()