結果
問題 | No.693 square1001 and Permutation 2 |
ユーザー | aguroshou |
提出日時 | 2018-06-08 23:03:45 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 548 bytes |
コンパイル時間 | 438 ms |
コンパイル使用メモリ | 61,436 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-13 00:09:22 |
合計ジャッジ時間 | 1,085 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,380 KB |
ソースコード
#include<iostream> #include <algorithm> #include<string> #include <bitset> using namespace std; int main() { //int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0; long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0; //cout << LONG_MAX << endl; long x[100001]; //string s[1001]; cin >> a; for ( b = 0; b < a; b++) { cin >> x[b]; } sort(x, x + a); for ( b = 0; b < a; b++) { ans+=abs(b + 1 - x[b]); } cout << ans << endl; //cout << "aaaaaaa" << endl; return 0; }