| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 168968 | pulpy_orange | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
int n;
cin>>n;
n=2*n;
int S[n];
for(int i=0;i<n;i++)cin>>S[i];
int ans=0;
int vis[n];
memset(vis, 0, sizeof(vis));
for(int i=0;i<n;i++){
if(vis[i])continue;
int curr=S[i];
vis[i]=1;
if(curr<0){
for(int j=i+1;j<n;j++){
if(!vis[j] and S[j]>0 and curr==-1*S[j]){
vis[j]=1;
ans+=(j-1-i);
break;
}
}
}
else{
for(int j=i+1;j<n;j++){
if(!vis[j] and S[j]<0 and curr==-1*S[j]){
vis[j]=1;
ans+=(j-i);
break;
}
}
}
}
cout<<ans;
}
