結果
問題 | No.693 square1001 and Permutation 2 |
ユーザー | tancahn2380 |
提出日時 | 2018-06-08 22:30:20 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,201 bytes |
コンパイル時間 | 901 ms |
コンパイル使用メモリ | 108,876 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 10:48:52 |
合計ジャッジ時間 | 1,454 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,944 KB |
ソースコード
# include <iostream> # include <algorithm> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <utility> # include <stack> # include <queue> # include <list> # include <tuple> # include <unordered_map> # include <numeric> # include <complex> # include <bitset> # include <random> # include <chrono> # include <cstdlib> # include <tuple> # include <array> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr int INF = 2147483647; constexpr int HINF = INF / 2; constexpr double DINF = 100000000000000000.0; constexpr double HDINF = 50000000000000000.0; constexpr long long LINF = 9223372036854775807; constexpr long long HLINF = 4500000000000000000; const double PI = acos(-1); template <typename T_char>T_char TL(T_char cX) { return tolower(cX); }; template <typename T_char>T_char TU(T_char cX) { return toupper(cX); }; const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 }; const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; } # define ALL(qpqpq) (qpqpq).begin(),(qpqpq).end() # define RALL(qpqpq) (qpqpq).rbegin(),(qpqpq).rend() # define UNIQUE(wpwpw) sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end()) # define LOWER(epepe) transform(ALL((epepe)),(epepe).begin(),TL<char>) # define UPPER(rprpr) transform(ALL((rprpr)),(rprpr).begin(),TU<char>) # define FOR(i,tptpt,ypypy) for(LL i=(tptpt);i<(ypypy);i++) # define RFOR(i,tptpt,ypypy) for(LL i=(tptpt);i>=(ypypy);i--) # define REP(i,upupu) FOR(i,0,upupu) # define INIT std::ios::sync_with_stdio(false);std::cin.tie(0) int n; int a[101010]; bool isok[101010]; int main() { cin >> n; REP(i, n) { cin >> a[i]; } sort(a, a + n); vector<int> v; REP(i, n) { if (!isok[a[i]]) { isok[a[i]] = true; } else { v.emplace_back(a[i]); } } int ans = 0; for (int i = 1; i <= n; i++) { if (!isok[i]) { ans += abs(v[v.size() - 1]-i); v.pop_back(); } } cout << ans << endl; }