# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
291555 | juggernaut | Arranging Shoes (IOI19_shoes) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include"shoes.h"
using namespace std;
typedef long long int ll;
long long count_swaps(vector<int>v){
ll cnt=0,q=0,i=0,j;
if(v.size()>2000){
for(;i<v.size();i++)
if(v[i]<0){
cnt+=abs(i-q);
q+=2;
}
return cnt;
}
for(;i<v.size();i+=2){
for(j=i;j<v.size();j++)if(a[i]==-a[j]){
q=j;
break;
}
while(q!=i+1){
swap(v[q],v[q-1]);
q--;
cnt++;
}
if(a[i]>a[i+1])cnt++;
}
return cnt;
}