#include <iostream>
#include <algorithm>
using namespace std;
int N;
int prerank[500001];
long long rankingSystem()
{
long long angry = 0;
for (int i = 1; i <= N; i++)
{
angry += abs(prerank[i] - i);
}
return angry;
}
int main()
{
cin >> N;
for (int i = 1; i <= N; i++)
{
cin >> prerank[i];
}
sort(prerank + 1, prerank + N + 1);
cout << rankingSystem();
}
'๐ก๐ธ๐ธ๐ถ๐ฃ: ๐๐๐๐๐๐พ๐๐ฝ๐ > ์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ํ์ด' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ1149 : RGB๊ฑฐ๋ฆฌ (Silver 1) (0) | 2021.08.17 |
---|---|
BOJ11660 : ๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ 5 (Silver 1) (0) | 2021.08.15 |
BOJ1343 : ํด๋ฆฌ์ค๋ฏธ๋ ธ (Silver 5) (0) | 2021.08.13 |
BOJ11170 : 0์ ๊ฐ์ (Silver 5) (0) | 2021.08.11 |
BOJ11068 : ํ๋ฌธ์ธ ์ (Silver 5) (0) | 2021.08.11 |