結果

問題 No.1041 直線大学
ユーザー snrnsidy
提出日時 2021-06-13 20:37:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 193,700 KB
最終ジャッジ日時 2025-01-22 08:00:58
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int X[100];
int Y[100];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int res = 0;
	int n;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> X[i] >> Y[i];
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int dy = Y[j] - Y[i];
			int dx = X[j] - X[i];
			int cnt = 0;
			for (int k = 0; k < n; k++)
			{
				int val = Y[i] * dx + dy * (X[k] - X[i]);
				if (val == dx * Y[k]) cnt++;
			}
			res = max(res, cnt);
		}
	}

	cout << res << '\n';

	return 0;
}
0