結果

問題 No.1041 直線大学
ユーザー RyumaRyamaRyumaRyama
提出日時 2020-05-01 22:44:41
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 129,612 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 17:54:41
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int i=0; i<n; i++) cin >> x[i] >> y[i];

    int ans = 0;
    for (int i=0; i<n-1; i++) {
        int cnt = 2;
        double a, b;
        a = (y[i]-y[i+1])/(x[i]-x[i+1]);
        b = y[i] - a*x[i];
        for (int j=i+2; j<n; j++)
            if (a*x[j]+b-0.1 < y[j] && y[j] < a*x[j]+b+0.1) cnt++;
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}
0