結果

問題 No.2812 Plus Minus Blackboard
ユーザー sakikuroesakikuroe
提出日時 2024-07-19 22:15:43
言語 Rust
(1.77.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 12,969 ms
コンパイル使用メモリ 389,820 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-07-21 20:27:53
合計ジャッジ時間 15,482 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 120 ms
10,240 KB
testcase_04 AC 68 ms
6,656 KB
testcase_05 AC 112 ms
9,728 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 98 ms
8,704 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 61 ms
6,400 KB
testcase_12 AC 47 ms
5,376 KB
testcase_13 AC 119 ms
10,112 KB
testcase_14 AC 28 ms
5,376 KB
testcase_15 AC 10 ms
5,376 KB
testcase_16 AC 102 ms
9,216 KB
testcase_17 AC 29 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 AC 81 ms
7,808 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 123 ms
10,112 KB
testcase_22 AC 105 ms
9,216 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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