結果
| 問題 |
No.693 square1001 and Permutation 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-02 02:23:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 314 bytes |
| コンパイル時間 | 622 ms |
| コンパイル使用メモリ | 64,248 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 14:36:33 |
| 合計ジャッジ時間 | 1,596 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int N,cost=0;
cin >> N;
vector<int> A(N);
for(int i=0;i<N;i++)cin >> A[i];
sort(A.begin(),A.end());
for(int k=0;k<N;k++){
cost+=abs(A[k]-k-1);
}
cout << cost << endl;
return 0;
}