結果

問題 No.693 square1001 and Permutation 2
ユーザー ナイーブ卍解
提出日時 2018-06-08 22:52:11
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 12,543 ms
コンパイル使用メモリ 400,684 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 10:55:03
合計ジャッジ時間 13,371 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{Read, stdin};

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut arr = vec![];
    
    for _ in 0..n {
        arr.push(get!());
    }
    
    arr.sort();
    
    let mut ans = 0;
    
    for i in 0..arr.len() {
        ans += (arr[i] - (i + 1) as i64).abs();
    }
    
    println!("{}", ans);
}
0