Submission #298827

#TimeUsernameProblemLanguageResultExecution timeMemory
298827Aldas25Arranging Shoes (IOI19_shoes)C++14
50 / 100
62 ms5112 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define f first #define s second #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<ll> vl; const int MAXN = 100100; bool ch[MAXN]; long long count_swaps(std::vector<int> s) { int n = (int)s.size(); ll ret = 0; FOR(i, 0, n-1) { if (ch[i]) continue; FOR(j, i+1, n-1) { if (ch[j]) continue; if (abs(s[i]) == abs(s[j]) && s[i] != s[j]) { ch[i] = ch[j] = true; if (s[i] > s[j]) ret++; break; } ret++; } } return ret; } /* 2 2 1 -1 -2 ans: 4 3 -2 2 2 -2 -2 2 ans: 1 */
#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...