結果

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

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const ld EPS = 0.000000001;

int main() {
    ld n;
    std::cin >> n;
    vector<ld> x(n),y(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i]>>y[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ll cnt = 0;
            if(x[i]==x[j]){
                for (int k = 0; k < n; k++) {
                    if(x[k]==x[i]){
                        cnt++;
                    }
                }
            }else{
                ld a = (y[i]-y[j])/(x[i]-x[j]);
                ld b = y[i]-a*x[i];
                for (int k = 0; k < n; k++) {
                    // std::cout << y[k]-a*x[k]-b << std::endl;
                    if(abs(y[k]-a*x[k]-b)<EPS){
                        cnt++;
                    }
                }
            }
            ans = max(cnt,ans);
        }
    }
    std::cout << ans << std::endl;
}
0