結果
| 問題 | No.693 square1001 and Permutation 2 | 
| コンテスト | |
| ユーザー |  matsuyoshi30 | 
| 提出日時 | 2018-06-08 23:32:34 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 138 ms / 2,000 ms | 
| コード長 | 412 bytes | 
| コンパイル時間 | 2,417 ms | 
| コンパイル使用メモリ | 74,380 KB | 
| 実行使用メモリ | 41,592 KB | 
| 最終ジャッジ日時 | 2024-06-30 11:09:42 | 
| 合計ジャッジ時間 | 4,232 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 9 | 
ソースコード
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) a[i] = in.nextInt();
        Arrays.sort(a);
        int sum = 0;
        for(int i=0; i<n; i++) {
            sum += Math.abs(a[i] - (i + 1));
        }
        System.out.println(sum);
    }
}
            
            
            
        