結果

問題 No.1373 Directed Operations
ユーザー tzyvrn
提出日時 2021-02-05 23:11:07
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 12,416 ms
コンパイル使用メモリ 403,608 KB
実行使用メモリ 10,516 KB
最終ジャッジ日時 2024-07-02 14:26:19
合計ジャッジ時間 15,866 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 7 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_macros)]
macro_rules! getl {
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_end();
            let mut ws = s.split_whitespace();
            ($(ws.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! getl_vec {
    ( $t:ty ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_end();
        s.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<$t>>()
    }};
}

fn main() {
    let n = getl!(usize);
    let a = getl_vec!(usize);
    let mut b = a.clone();
    b.sort();

    let mut v = vec![vec![]; n];
    for i in 1..n {
        let bi = b[i - 1];
        if bi > i {
            println!("NO");
            return;
        }
        v[bi].push(i - bi);
    }

    println!("YES");
    for ai in a {
        let c = v[ai].pop().unwrap();
        println!("{}", c);
    }
}
0