結果

問題 No.1041 直線大学
ユーザー xRS43BofaUEZ5gc
提出日時 2021-03-29 15:54:17
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,051 bytes
コンパイル時間 5,471 ms
コンパイル使用メモリ 77,028 KB
実行使用メモリ 56,104 KB
最終ジャッジ日時 2024-11-29 10:05:59
合計ジャッジ時間 10,801 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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 ++) {
					double k = (positions[i][0] - positions[j][0]) == 0 ? 0 :
							(positions[i][1] - positions[j][1])/(positions[i][0] - positions[j][0]);
					double b = positions[i][1] - k * positions[i][0];
					int count_temp = 0;
					for (int ni = 0; ni < n; ni ++) {
						if (k * positions[ni][0] + b == positions[ni][1]) {
							count_temp ++;
						}
					}
					if (count_temp > count) {
						count = count_temp;
					}
				}
			}
			int count_temp = 0;
			for (int ni = 0; ni < n; ni ++) {

				if (positions[ni][0] == 0) {
					count_temp ++;
				}
			}
			if (count_temp > count) {
				count = count_temp;
			}
			System.out.println(count);
	}
}
0