結果

問題 No.1041 直線大学
コンテスト
ユーザー xRS43BofaUEZ5gc
提出日時 2021-03-29 16:07:24
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 892 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,200 ms
コンパイル使用メモリ 84,120 KB
実行使用メモリ 43,440 KB
最終ジャッジ日時 2026-05-11 13:37:12
合計ジャッジ時間 6,990 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Scanner;

public class HelloWorld {
		public static void main (String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int[][] positions = new int[n][2];
			for (int i = 0; i < n; i ++) {
				positions[i][0] = sc.nextInt();
				positions[i][1] = sc.nextInt();
			}

			int count = 1;

			for (int i = 0; i < n; i ++) {
				for (int j = i+1; j < n; j ++) {
					long deltax1 = positions[i][0] - positions[j][0];
					long deltay1 = positions[i][1] - positions[j][1];
					int count_temp = 0;
					for (int ni = 0; ni < n; ni ++) {
						long deltax2 = positions[ni][0] - positions[j][0];
						long deltay2 = positions[ni][1] - positions[j][1];
						if (deltax1 * deltay2 == deltax2 * deltay1) {
							count_temp ++;
						}
					}
					if (count_temp > count) {
						count = count_temp;
					}
				}
			}
			
			System.out.println(count);
	}
}
0