結果

問題 No.2812 Plus Minus Blackboard
ユーザー sakikuroe
提出日時 2024-07-19 22:10:04
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 12,392 ms
コンパイル使用メモリ 405,808 KB
実行使用メモリ 17,024 KB
最終ジャッジ日時 2025-04-08 23:43:30
合計ジャッジ時間 12,594 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::{fastout, input};
use std::collections::BTreeSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut set = BTreeSet::new();

    let mut t = 0;

    for i in 0..n {
        set.insert((a[i], t));
        t += 1;
    }

    for _ in 0..n - 1 {
        let x = set.range((0, 0)..).next();
        if x.is_none() {
            println!("No");
            return;
        }

        let y = set.range(..=(0, i32::MAX)).next();
        if y.is_none() {
            println!("No");
            return;
        }

        set.insert((x.unwrap().0 + y.unwrap().0, t));
        t += 1;
    }

    println!("Yes");
}
0