結果
問題 | No.1041 直線大学 |
ユーザー | tenten |
提出日時 | 2022-09-13 18:37:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 2,219 bytes |
コンパイル時間 | 2,525 ms |
コンパイル使用メモリ | 77,656 KB |
実行使用メモリ | 38,024 KB |
最終ジャッジ日時 | 2024-11-16 08:14:42 |
合計ジャッジ時間 | 4,963 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
36,744 KB |
testcase_01 | AC | 45 ms
36,648 KB |
testcase_02 | AC | 46 ms
36,724 KB |
testcase_03 | AC | 45 ms
36,928 KB |
testcase_04 | AC | 49 ms
36,772 KB |
testcase_05 | AC | 47 ms
36,700 KB |
testcase_06 | AC | 48 ms
36,800 KB |
testcase_07 | AC | 49 ms
36,952 KB |
testcase_08 | AC | 48 ms
36,724 KB |
testcase_09 | AC | 48 ms
36,516 KB |
testcase_10 | AC | 65 ms
38,016 KB |
testcase_11 | AC | 69 ms
38,024 KB |
testcase_12 | AC | 58 ms
37,180 KB |
testcase_13 | AC | 46 ms
36,864 KB |
testcase_14 | AC | 50 ms
36,944 KB |
testcase_15 | AC | 47 ms
37,176 KB |
testcase_16 | AC | 48 ms
37,136 KB |
testcase_17 | AC | 46 ms
36,932 KB |
testcase_18 | AC | 47 ms
36,836 KB |
testcase_19 | AC | 53 ms
36,632 KB |
testcase_20 | AC | 48 ms
36,996 KB |
testcase_21 | AC | 51 ms
36,864 KB |
testcase_22 | AC | 50 ms
37,004 KB |
testcase_23 | AC | 67 ms
37,780 KB |
testcase_24 | AC | 55 ms
37,040 KB |
testcase_25 | AC | 52 ms
36,976 KB |
testcase_26 | AC | 50 ms
36,732 KB |
testcase_27 | AC | 47 ms
37,048 KB |
testcase_28 | AC | 45 ms
36,988 KB |
testcase_29 | AC | 47 ms
36,972 KB |
testcase_30 | AC | 45 ms
36,924 KB |
testcase_31 | AC | 46 ms
36,648 KB |
testcase_32 | AC | 47 ms
36,988 KB |
testcase_33 | AC | 48 ms
36,916 KB |
testcase_34 | AC | 45 ms
36,404 KB |
testcase_35 | AC | 49 ms
37,048 KB |
testcase_36 | AC | 43 ms
36,736 KB |
testcase_37 | AC | 45 ms
36,700 KB |
testcase_38 | AC | 58 ms
37,472 KB |
testcase_39 | AC | 47 ms
36,864 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); Point[] points = new Point[n]; for (int i = 0; i < n; i++) { points[i] = new Point(sc.nextInt(), sc.nextInt()); } int max = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { Line line = points[i].getLine(points[j]); int count = 0; for (int k = j + 1; k < n; k++) { if (line.contains(points[k])) { count++; } } max = Math.max(max, count + 2); } } System.out.println(max); } static class Point { int x; int y; public Point(int x, int y) { this.x = x; this.y = y; } public Line getLine(Point p) { return new Line(y - p.y, x - p.x, x, y); } } static class Line { int a; int b; int x; int y; public Line(int a, int b, int x, int y) { this.a = a; this.b = b; this.x = x; this.y = y; } public boolean contains(Point p) { return a * (p.x - x) - b * (p.y - y) == 0; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }