結果

問題 No.1285 ゴミ捨て
ユーザー fukafukatani
提出日時 2020-11-13 21:32:31
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 13,390 ms
コンパイル使用メモリ 378,912 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-07-22 20:31:43
合計ジャッジ時間 14,754 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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