Submission #1242743

#TimeUsernameProblemLanguageResultExecution timeMemory
1242743mohamedboukerche55Arranging Shoes (IOI19_shoes)C++20
10 / 100
1 ms328 KiB
// batata raha tdir 1200 da fi bel abbes #include <bits/stdc++.h> #include "shoes.h" using namespace std; using ll = long long; const int MAXA = 1e9 + 123; ll count_swaps(vector<int> S) { ll res = MAXA; int n = S.size(); vector<int> vec = S; sort(vec.begin(), vec.end()); for (int i = 1; i <= n / 2; i ++) { vec.pop_back(); } vector<int> s ; s = S; vector<int> t; for (int val : vec) { t.push_back(val); t.push_back(-val); } int ans = 0; for (int i = 0; i < n; i ++) { int j; for (j = i; j < n; j ++) { if (s[j] == t[i]) { break; } } while (j > i) { swap(s[j - 1], s[j]); j --; ans ++; } res = min(res, 1ll * ans); } //while (next_permutation(vec.begin(), vec.end())); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...