結果
問題 | No.1285 ゴミ捨て |
ユーザー |
![]() |
提出日時 | 2020-11-13 21:37:06 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 13,048 ms |
コンパイル使用メモリ | 391,044 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-28 21:44:25 |
合計ジャッジ時間 | 12,560 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
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; } 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() }