結果

問題 No.1041 直線大学
ユーザー nephrologistnephrologist
提出日時 2020-05-01 23:54:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-28 00:14:25
合計ジャッジ時間 3,213 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,880 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 25 ms
10,880 KB
testcase_03 AC 26 ms
10,880 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 25 ms
10,880 KB
testcase_06 AC 25 ms
10,880 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 29 ms
10,880 KB
testcase_09 AC 29 ms
10,880 KB
testcase_10 AC 172 ms
11,392 KB
testcase_11 AC 175 ms
11,264 KB
testcase_12 AC 189 ms
11,392 KB
testcase_13 AC 32 ms
11,008 KB
testcase_14 AC 98 ms
11,392 KB
testcase_15 AC 41 ms
11,008 KB
testcase_16 AC 82 ms
11,264 KB
testcase_17 AC 28 ms
10,880 KB
testcase_18 AC 48 ms
11,008 KB
testcase_19 AC 79 ms
11,136 KB
testcase_20 AC 25 ms
10,880 KB
testcase_21 AC 51 ms
11,008 KB
testcase_22 AC 25 ms
10,880 KB
testcase_23 AC 150 ms
11,392 KB
testcase_24 AC 92 ms
11,264 KB
testcase_25 AC 55 ms
11,136 KB
testcase_26 AC 29 ms
10,880 KB
testcase_27 AC 38 ms
11,008 KB
testcase_28 AC 25 ms
10,880 KB
testcase_29 AC 26 ms
11,008 KB
testcase_30 AC 26 ms
10,880 KB
testcase_31 AC 26 ms
11,008 KB
testcase_32 AC 25 ms
10,880 KB
testcase_33 AC 26 ms
11,008 KB
testcase_34 AC 27 ms
11,008 KB
testcase_35 AC 26 ms
10,880 KB
testcase_36 AC 25 ms
11,008 KB
testcase_37 AC 25 ms
10,880 KB
testcase_38 AC 185 ms
11,520 KB
testcase_39 AC 37 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import defaultdict, Counter

n = int(input())
XY = []
for i in range(n):
    x, y = map(int, input().split())
    XY.append((x, y))


def line_calc(x1, y1, x2, y2):
    return -(y1 - y2), (x1 - x2), y1 * (x1 - x2) - x1 * (y1 - y2)


def check_line(a, b, c, x, y):
    return a * x + b * y == c


if n == 2:
    print(2)
else:
    line = []
    for i in range(n - 1):
        for j in range(i + 1, n):
            x1, y1 = XY[i]
            x2, y2 = XY[j]
            line.append(line_calc(x1, y1, x2, y2))
    ans = 0
    for pair in line:
        cnt = 0
        a, b, c = pair
        for x, y in XY:
            if check_line(a, b, c, x, y):
                cnt += 1
        ans = max(cnt, ans)
    print(ans)
0