結果

問題 No.1041 直線大学
ユーザー joybeeee
提出日時 2020-05-13 10:43:07
言語 Java
(openjdk 23)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 77,476 KB
実行使用メモリ 41,580 KB
最終ジャッジ日時 2024-11-16 08:03:06
合計ジャッジ時間 7,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[][] points = new int[n][2];
      for(int i = 0; i < n; i++) {
        points[i][0] = sc.nextInt();
        points[i][1] = sc.nextInt();
      }
      int max = 0;
      for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
          int cnt = 2;
          int dx = points[i][0] - points[j][0];
          int dy = points[i][1] - points[j][1];
          for(int k = 0; k < n; k++) {
              if(k == i || k == j) continue;
              int dxk = points[i][0] - points[k][0];
              int dyk = points[i][1] - points[k][1];
              if(dx * dyk == dy * dxk) cnt++;
          }
          max = Math.max(max, cnt);
        }
      }
      System.out.println(max);
  }
}
0