結果
| 問題 | No.693 square1001 and Permutation 2 | 
| コンテスト | |
| ユーザー |  ngtkana | 
| 提出日時 | 2020-02-27 12:57:47 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 301 bytes | 
| コンパイル時間 | 1,786 ms | 
| コンパイル使用メモリ | 171,056 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-13 15:51:59 | 
| 合計ジャッジ時間 | 1,993 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 9 | 
ソースコード
#include<bits/stdc++.h>
int main(){
    int n;std::cin>>n;
    std::vector<int>a(n);
    for(int i=0;i<n;i++)std::cin>>a.at(i);
    std::sort(a.begin(),a.end());
    int ans=0;
    for(int i=0;i<n;i++){
        int x=a.at(i)-(i+1);
        ans+=std::max(x,-x);
    }
    std::cout<<ans<<std::endl;
}
            
            
            
        