結果
問題 | No.693 square1001 and Permutation 2 |
ユーザー |
![]() |
提出日時 | 2018-06-19 02:48:31 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 414 bytes |
コンパイル時間 | 653 ms |
コンパイル使用メモリ | 65,892 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 17:10:12 |
合計ジャッジ時間 | 1,170 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 |
ソースコード
#include<stdio.h>#include<iostream>#include<vector>#include<cstdlib>#include<algorithm>using namespace std;int N;vector<int> v;int main (){cin >> N;for(int i=0; i<N; i++){int a;cin >> a;v.push_back(a);}sort( v.begin(), v.end());int cost = 0;for(int i=1; i<N+1; i++){cost += abs(i - v[i-1]);}cout << cost << endl;return 0;}