結果

問題 No.2812 Plus Minus Blackboard
ユーザー sakikuroe
提出日時 2024-07-19 22:15:43
言語 Rust
(1.83.0 + proconio)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 747 bytes
コンパイル時間 11,479 ms
コンパイル使用メモリ 400,012 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2025-04-09 08:38:26
合計ジャッジ時間 13,696 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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 {
        if let Some(&x) = set.range((0, 0)..).next() {
            set.remove(&x);
            if let Some(&y) = set.range(..=(0, i32::MAX)).last() {
                set.remove(&y);
                set.insert((x.0 + y.0, t));
                t += 1;
            } else {
                println!("No");
                return;
            }
        } else {
            println!("No");
            return;
        }
    }

    println!("Yes");
}
0