結果

問題 No.1041 直線大学
ユーザー qLethon
提出日時 2020-05-01 22:04:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,051 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 194,480 KB
最終ジャッジ日時 2025-01-10 04:52:39
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> X(n), Y(n);
    for (int i = 0; i < n; i++)
        cin >> X[i] >> Y[i];

    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            if (X[i] == X[j])
                continue;
            int dx = X[i] - X[j];
            int dy = Y[i] - Y[j];

            int res = 0;
            for (int k = 0; k < n; k++){
                if (dy * (X[k] - X[i]) % dx != 0)
                    continue;
                int y = dy * (X[k] - X[i]) / dx + Y[i];
                if (y == Y[k])
                    res++;
            }
            ans = max(ans, res);
        }
    }

    for (int i = 0; i <= 100; i++){
        int res = 0;
        for (int j = 0; j < n; j++)
            if (X[j] == i)
                res++;
        ans = max(ans, res);
        res = 0;
        for (int j = 0; j < n; j++)
            if (Y[j] == i)
                res++;
        ans = max(ans, res);
    }

    cout << ans << endl;
}
0