結果
| 問題 | No.693 square1001 and Permutation 2 |
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2019-11-12 07:39:01 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 404 bytes |
| 記録 | |
| コンパイル時間 | 1,797 ms |
| コンパイル使用メモリ | 82,060 KB |
| 実行使用メモリ | 42,060 KB |
| 最終ジャッジ日時 | 2026-04-06 05:42:10 |
| 合計ジャッジ時間 | 3,092 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 |
ソースコード
import java.util.*;
public class Main {
public static void main (String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
int total = 0;
for (int i = 1; i <= n; i++) {
total += Math.abs(arr[i - 1] - i);
}
System.out.println(total);
}
}
htensai