제출 #708010

#제출 시각아이디문제언어결과실행 시간메모리
708010MODDIArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms300 KiB
//#include "shoes.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second;
using namespace std;
long long count_swaps(std::vector<int> s) {
	ll ans = 0;
	vi arr = s;
	int n = s.size();
	for(int i = 0; i < n; i+=2){
		int target = arr[i] * -1;
		int j = i + 1;
		if(arr[i] * -1 == arr[i+1]){
			if(arr[i] < 0)	continue;
			else{
				ans++;
				continue;
			}
		}
		while(j < n && arr[i] != target)
		{
			j++;
		}
		for(int at = j; at > i+1; at--){
			swap(arr[at], arr[at-1]);
			ans++;
		}
		if(target > 0){
			ans++;
		}
	}
	return ans;
}
#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...