結果

問題 No.693 square1001 and Permutation 2
ユーザー ekidenpekidenp
提出日時 2018-06-08 22:32:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 4,331 ms
コンパイル使用メモリ 105,376 KB
実行使用メモリ 22,868 KB
最終ジャッジ日時 2023-09-12 23:57:35
合計ジャッジ時間 4,892 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
22,592 KB
testcase_01 AC 54 ms
20,736 KB
testcase_02 AC 57 ms
20,528 KB
testcase_03 AC 59 ms
22,728 KB
testcase_04 AC 57 ms
22,728 KB
testcase_05 AC 54 ms
20,680 KB
testcase_06 AC 60 ms
22,868 KB
testcase_07 AC 58 ms
22,720 KB
testcase_08 AC 57 ms
20,712 KB
testcase_09 AC 58 ms
22,580 KB
testcase_10 AC 57 ms
18,692 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		int[] A = new int[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
		}
		Array.Sort(A);
		int sum = 0;
		for(var i=0;i<N;i++){
			sum += Math.Abs(A[i]-(i+1));
		}
		Console.WriteLine(sum);
	}
}
0