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"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long count_swaps(std::vector<int> s) {
int n=s.size();
if (n==2)
{
if (s[0]<0) return 0;
else return 1;
}
bool isti=true;
for (int i=1; i<n; i++)
if (abs(s[i])!=abs(s[i-1])) { isti=false; break; }
if (isti)
{
int gde=1;
ll ress=0;
for (int i=0; i<n; i++)
{
if (s[i]>0)
{
ress+=abs(i-gde);
gde+=2;
}
}
return ress;
}
else return (ll)(n*n/4);
}
# | 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... |