結果

問題 No.1041 直線大学
ユーザー taku-techtaku-tech
提出日時 2021-05-23 05:29:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,141 bytes
コンパイル時間 3,709 ms
コンパイル使用メモリ 77,516 KB
実行使用メモリ 41,832 KB
最終ジャッジ日時 2024-04-28 00:18:47
合計ジャッジ時間 8,316 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
41,064 KB
testcase_01 AC 107 ms
40,844 KB
testcase_02 AC 107 ms
41,172 KB
testcase_03 AC 98 ms
39,920 KB
testcase_04 AC 103 ms
41,068 KB
testcase_05 AC 105 ms
41,292 KB
testcase_06 AC 104 ms
41,236 KB
testcase_07 AC 110 ms
41,240 KB
testcase_08 AC 110 ms
40,884 KB
testcase_09 AC 109 ms
41,220 KB
testcase_10 AC 129 ms
41,200 KB
testcase_11 AC 120 ms
40,896 KB
testcase_12 AC 132 ms
41,832 KB
testcase_13 AC 116 ms
41,340 KB
testcase_14 AC 145 ms
41,504 KB
testcase_15 AC 134 ms
41,568 KB
testcase_16 AC 127 ms
41,276 KB
testcase_17 AC 116 ms
41,176 KB
testcase_18 AC 112 ms
41,056 KB
testcase_19 AC 121 ms
41,232 KB
testcase_20 AC 105 ms
40,036 KB
testcase_21 AC 120 ms
41,168 KB
testcase_22 AC 103 ms
40,348 KB
testcase_23 AC 127 ms
41,336 KB
testcase_24 AC 130 ms
41,380 KB
testcase_25 AC 124 ms
41,508 KB
testcase_26 AC 114 ms
41,108 KB
testcase_27 AC 114 ms
41,100 KB
testcase_28 AC 102 ms
41,100 KB
testcase_29 AC 94 ms
40,052 KB
testcase_30 AC 90 ms
39,972 KB
testcase_31 AC 100 ms
40,916 KB
testcase_32 AC 94 ms
39,908 KB
testcase_33 AC 104 ms
41,224 KB
testcase_34 AC 102 ms
41,332 KB
testcase_35 AC 108 ms
40,348 KB
testcase_36 AC 110 ms
41,212 KB
testcase_37 AC 109 ms
41,268 KB
testcase_38 AC 134 ms
41,472 KB
testcase_39 AC 113 ms
40,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package coord_count;

import java.util.Scanner;

class Point {
	private int x;
	private int y;

	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return this.x;
	}

	public int getY() {
		return this.y;
	}
}

public class CoordCount {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);


		int N = sc.nextInt();
		Point[] points = new Point[N];

		for(int i = 0; i <N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			points[i] = new Point(x, y);
		}

		System.out.println(maxCnt(points));
	}

	private static int maxCnt(Point[] points) {
		int maxCnt = 0;

		for(int i = 0; i < points.length - 1; i++) {
			for(int j = (i + 1); j < points.length; j++) {
				int cnt = 2;
				int dx = points[i].getX() - points[j].getX();
				int dy = points[i].getY() - points[j].getY();
				for(int k = (j + 1); k < points.length; k++) {
					int nx = points[i].getX() - points[k].getX();
					int ny = points[i].getY() - points[k].getY();
					if(dx * ny == dy * nx) {
						cnt++;
					}
				}
				if(maxCnt < cnt) {
					maxCnt = cnt;
				}
			}

		}

		return maxCnt;
	}

}
0