Submission #297324

#TimeUsernameProblemLanguageResultExecution timeMemory
297324amoo_safarArranging Shoes (IOI19_shoes)C++17
30 / 100
44 ms8720 KiB
#include "shoes.h"

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end();

using namespace std;

typedef long long ll;

const int N = 2e5 + 10;
vector<int> V[N];

ll count_swaps(vector<int> s) {
	int n = s.size() >> 1;
	for(int i = 0; i < n + n; i++){
		V[abs(s[i])].pb(s[i] < 0 ? -1 : +1);
	}
	int sm = 0;
	ll res = 0;
	for(int i = 1; i <= n; i++){
		sm = 0;
		for(int j = 0; j < (int) V[i].size(); j++){
			if(V[i][j] == 1) sm ++;
			res += abs(sm - ((j + 1) / 2));
		}
	}
	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...