結果
| 問題 |
No.693 square1001 and Permutation 2
|
| コンテスト | |
| ユーザー |
hatsuka_iwa
|
| 提出日時 | 2021-02-04 02:44:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 461 bytes |
| コンパイル時間 | 1,532 ms |
| コンパイル使用メモリ | 168,932 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 09:34:06 |
| 合計ジャッジ時間 | 2,252 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, ans = 0;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
int tmp;
cin >> tmp;
A.at(tmp - 1)++;
}
for (int i = 0; i < N; i++) {
while (A.at(i) > 1) {
for (int j = 0; j < N; j++) {
if (A.at(j) == 0) {
ans += abs(i - j);
A.at(i)--;
A.at(j)++;
break;
}
}
}
}
cout << ans << endl;
}
hatsuka_iwa