結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-07 13:36:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 912 bytes |
| コンパイル時間 | 268 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-11-16 08:15:01 |
| 合計ジャッジ時間 | 2,642 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
from collections import Counter
def main():
N = int(input())
coordinates = set()
max_point_num = 0
for _ in range(N):
x, y = map(int, input().split())
coordinates.add((x, y))
for point in coordinates:
origin_shifted = list(
map(
lambda coord: (coord[0]-point[0], coord[1]-point[1]),
coordinates
)
)
slopes = []
for coord in origin_shifted:
if coord[0] == 0 and coord[1] == 0:
continue
try:
slopes.append(coord[1]/coord[0])
except ZeroDivisionError:
slopes.append(None)
counter = Counter(slopes)
_, points_num = counter.most_common(1)[0]
if max_point_num < points_num:
max_point_num = points_num
print(max_point_num + 1)
if __name__ == "__main__":
main()