結果

問題 No.1041 直線大学
ユーザー yomo3
提出日時 2020-05-08 12:24:42
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 1,009 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 78,896 KB
実行使用メモリ 56,548 KB
最終ジャッジ日時 2024-07-03 09:48:45
合計ジャッジ時間 8,492 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 2
other AC * 10 RE * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.awt.Point;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Point[] p = new Point[N];
        for (Point e: p) {
            e = new Point(sc.nextInt(), sc.nextInt());
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                int cnt = 2;
                for (int k = j + 1; k < N; k++) {
                    if (isCollinear(p[i], p[j], p[k])) {
                        cnt++;
                    }
                }
                ans = Math.max(ans, cnt);
            }
        }
        System.out.println(ans);
    }

    static boolean isCollinear(Point a, Point b, Point c) {
        // if (a.x == b.x && a.y == b.y) return false;
        if (a.x == b.x) return a.x == c.x;
        if (a.y == b.y) return a.y == c.y;
        return a.x*b.y-b.x*a.y + b.x*c.y-c.x*b.y + c.x*a.y-a.x*c.y == 0;
    }

}
0