結果

問題 No.1041 直線大学
ユーザー tonyu0
提出日時 2020-05-01 22:23:39
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 16,923 ms
コンパイル使用メモリ 378,340 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 12:56:02
合計ジャッジ時間 18,896 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<(f64, f64)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut ans = 0;

    for i in 0..n {
        for j in i + 1..n {
            let b = (a[j].1 - a[i].1) / (a[j].0 - a[i].0);
            let c = a[j].1 - b * a[j].0;
            let mut cnt = 0;
            for k in 0..n {
                if k == i || k == j {
                    continue;
                }
                if a[k].1 == b * a[k].0 + c {
                    cnt += 1;
                }
            }
            ans = std::cmp::max(ans, cnt + 2);
        }
    }
    println!("{}", ans);
}
0