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 "shoes.h"
using namespace std;
#define nmax 100000
int v[nmax];
int n;
int find_pair( int l ) {
int i, j;
if( v[l] < 0 ) {
for( i = l + 1; i < n; i++ ) {
if( v[i] + v[l] == 0 )
break;
}
for( j = i; j > l + 1; j-- )
v[j] = v[j - 1];
return i - l - 1;
} else {
for( i = l + 1; i < n; i++ ) {
if( v[i] + v[l] == 0 )
break;
}
for( j = i; j > l + 1; j-- )
v[j] = v[j - 1];
return i - l;
}
}
long long count_swaps( vector<int> s) {
int i, l, rez = 0;
n = s.size();
for( i = 0; i < n; i++ )
v[i] = s[i];
for( l = 0; l < n; l += 2 ) {
rez += find_pair( l );
}
return rez;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |