結果

問題 No.851 テストケース
コンテスト
ユーザー iwot
提出日時 2019-08-13 21:03:50
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 1,034 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 744 ms
コンパイル使用メモリ 204,548 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-08 00:42:21
合計ジャッジ時間 2,176 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> src/main.rs:17:9
   |
17 |     for i in 0..count {
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_one<T: std::str::FromStr>() -> Option<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok()
}

fn main() {
    let count: i32 = read();

    let mut numbers: Vec<i32> = vec![];
    for i in 0..count {
        let input: Option<i32> = read_one();
        if input.is_none() {
            println!("\"assert\"");
            std::process::exit(0);
        }
        numbers.push(input.unwrap());
    }

    let mut new_numbers = vec![];
    for i in 0..numbers.len() {
        for j in 0..numbers.len() {
            if i == j {
                continue;
            }
            let n = numbers[i] + numbers[j];
            if !new_numbers.contains(&n) {
                new_numbers.push(n);
            }
        }
    }
    new_numbers.sort_by(|a, b| b.partial_cmp(a).unwrap());
    println!("{}", new_numbers[1]);
}

0