結果

問題 No.1041 直線大学
ユーザー yomo3yomo3
提出日時 2020-05-08 12:24:42
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,009 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 58,392 KB
最終ジャッジ日時 2023-09-16 08:23:48
合計ジャッジ時間 8,765 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,148 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 120 ms
56,080 KB
testcase_29 AC 120 ms
56,152 KB
testcase_30 AC 120 ms
56,120 KB
testcase_31 AC 120 ms
55,700 KB
testcase_32 AC 119 ms
56,324 KB
testcase_33 AC 121 ms
56,588 KB
testcase_34 AC 120 ms
55,880 KB
testcase_35 AC 122 ms
56,416 KB
testcase_36 AC 121 ms
55,976 KB
testcase_37 AC 121 ms
55,708 KB
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

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