結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-08 12:28:33 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 2,000 ms |
| コード長 | 1,023 bytes |
| コンパイル時間 | 2,145 ms |
| コンパイル使用メモリ | 78,452 KB |
| 実行使用メモリ | 41,552 KB |
| 最終ジャッジ日時 | 2024-11-16 08:02:15 |
| 合計ジャッジ時間 | 8,651 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
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 (int i = 0; i < N; i++) {
p[i] = 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;
}
}