結果
問題 | No.1041 直線大学 |
ユーザー | tenten |
提出日時 | 2022-09-13 18:37:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 2,219 bytes |
コンパイル時間 | 2,383 ms |
コンパイル使用メモリ | 78,156 KB |
実行使用メモリ | 38,384 KB |
最終ジャッジ日時 | 2024-04-28 00:19:33 |
合計ジャッジ時間 | 5,493 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,120 KB |
testcase_01 | AC | 53 ms
37,248 KB |
testcase_02 | AC | 54 ms
37,268 KB |
testcase_03 | AC | 53 ms
37,108 KB |
testcase_04 | AC | 54 ms
37,276 KB |
testcase_05 | AC | 54 ms
36,836 KB |
testcase_06 | AC | 54 ms
37,116 KB |
testcase_07 | AC | 54 ms
37,340 KB |
testcase_08 | AC | 55 ms
37,340 KB |
testcase_09 | AC | 55 ms
37,340 KB |
testcase_10 | AC | 72 ms
38,108 KB |
testcase_11 | AC | 68 ms
38,052 KB |
testcase_12 | AC | 68 ms
37,988 KB |
testcase_13 | AC | 55 ms
37,212 KB |
testcase_14 | AC | 60 ms
37,564 KB |
testcase_15 | AC | 55 ms
37,220 KB |
testcase_16 | AC | 58 ms
37,432 KB |
testcase_17 | AC | 54 ms
37,284 KB |
testcase_18 | AC | 56 ms
37,448 KB |
testcase_19 | AC | 59 ms
36,944 KB |
testcase_20 | AC | 53 ms
36,952 KB |
testcase_21 | AC | 57 ms
37,212 KB |
testcase_22 | AC | 54 ms
37,164 KB |
testcase_23 | AC | 66 ms
38,384 KB |
testcase_24 | AC | 59 ms
37,208 KB |
testcase_25 | AC | 57 ms
37,240 KB |
testcase_26 | AC | 55 ms
37,284 KB |
testcase_27 | AC | 55 ms
37,232 KB |
testcase_28 | AC | 54 ms
37,316 KB |
testcase_29 | AC | 54 ms
37,116 KB |
testcase_30 | AC | 54 ms
37,092 KB |
testcase_31 | AC | 54 ms
36,824 KB |
testcase_32 | AC | 54 ms
36,816 KB |
testcase_33 | AC | 53 ms
37,088 KB |
testcase_34 | AC | 53 ms
37,112 KB |
testcase_35 | AC | 53 ms
37,036 KB |
testcase_36 | AC | 54 ms
37,144 KB |
testcase_37 | AC | 54 ms
36,948 KB |
testcase_38 | AC | 69 ms
37,936 KB |
testcase_39 | AC | 55 ms
37,192 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(); } }