Submission #1242563

#TimeUsernameProblemLanguageResultExecution timeMemory
1242563haithamcoderArranging Shoes (IOI19_shoes)C++20
45 / 100
14 ms1864 KiB

#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define db(x) cerr << #x << " = " << x << " | "
#define dbg(x) cerr << #x << " = " << x << "\n"


long long count_swaps(std::vector<int> s) {
	ll n = s.size()/2;

	ll t = 0, p = 0; 
	
	for (ll i = 0; i < 2 * n; i++) {
		if (s[i] < 0) {
			// dbg("here");
			t += abs(i - p);
			p += 2;
		}	
	}

	return t;
}
#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...