結果
| 問題 | No.693 square1001 and Permutation 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-02 02:23:06 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 314 bytes |
| 記録 | |
| コンパイル時間 | 762 ms |
| コンパイル使用メモリ | 82,864 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-03-15 13:52:40 |
| 合計ジャッジ時間 | 1,327 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}