結果
| 問題 | 
                            No.1285 ゴミ捨て
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-01-10 01:16:52 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 998 bytes | 
| コンパイル時間 | 28,168 ms | 
| コンパイル使用メモリ | 390,224 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2025-02-21 06:58:45 | 
| 合計ジャッジ時間 | 16,535 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 22 | 
ソースコード
#[macro_export]
macro_rules! setup {
    { mut $input:ident: SplitWhitespace $(,)? } => {
        use std::io::Read;
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut $input = buf.split_whitespace();
    };
}
#[macro_export]
macro_rules! parse_next {
    ($str_iter:expr) => {
        $str_iter.next().unwrap().parse().unwrap()
    };
}
fn main() {
    setup! { mut input: SplitWhitespace };
    let n: usize = parse_next!(input);
    let mut a: Vec<usize> = (0..n).map(|_| parse_next!(input)).collect();
    a.sort();
    let mut count = 0;
    while !a.is_empty() {
        let mut idxs = vec![0];
        let mut size = a[0];
        for i in 1..a.len() {
            if size + 1 < a[i] {
                idxs.push(i);
                size = a[i];
            }
        }
        idxs.reverse();
        for idx in idxs.into_iter() {
            a.remove(idx);
        }
        count += 1;
    }
    println!("{}", count);
}