結果

問題 No.1041 直線大学
ユーザー ninoinui
提出日時 2020-06-27 10:53:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 1,855 ms
コンパイル使用メモリ 195,784 KB
最終ジャッジ日時 2025-01-11 12:40:26
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> V(N);
  for (int i = 0, x, y; cin >> x >> y; i++) V.at(i) = {x, y};
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      auto[x1, y1] = V.at(i);
      auto[x2, y2] = V.at(j);
      double tmp = (double) (y1 - y2) / (x1 - x2);
      int cnt = 2;
      for (int k = 0; k < N; k++) {
        if (k == i) continue;
        if (k == j) continue;
        auto[x3, y3] = V.at(k);
        if ((y1 - y3) / (double) (x1 - x3) == tmp) cnt++;
      }
      ans = max(ans, cnt);
    }
  }
  cout << ans << "\n";
}
0