結果

問題 No.1285 ゴミ捨て
ユーザー fukafukatanifukafukatani
提出日時 2020-11-13 21:32:31
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 1,321 ms
コンパイル使用メモリ 157,708 KB
実行使用メモリ 6,604 KB
最終ジャッジ日時 2023-09-30 02:36:50
合計ジャッジ時間 3,063 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 51 ms
6,400 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 20 ms
4,380 KB
testcase_10 AC 44 ms
5,744 KB
testcase_11 AC 40 ms
5,528 KB
testcase_12 AC 29 ms
4,536 KB
testcase_13 AC 29 ms
4,540 KB
testcase_14 AC 48 ms
6,076 KB
testcase_15 AC 34 ms
4,860 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 19 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 11 ms
4,376 KB
testcase_22 AC 54 ms
6,552 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::*;
use std::ops::Bound::*;

fn main() {
    let n = read::<usize>();
    let mut a = BTreeSet::new();
    for i in 0..n {
        a.insert((read::<i64>(), i));
    }
    let mut ans = 0;
    while let Some(&(size, idx)) = a.iter().next() {
        ans += 1;
        let mut used = vec![(size, idx)];
        let mut cur = size;
        while let Some(&(ns, nidx)) = a.range((Included((cur + 2, 0)), Unbounded)).next() {
            used.push((ns, nidx));
            cur = ns + 2;
        }
        for elem in used {
            a.remove(&elem);
        }
    }
    println!("{}", ans);
}

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()
}
0