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 <cstdio>
#include <algorithm>
using namespace std;
int main(){
int n,a[5005];
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
}
int ret = 0;
for (int i=0; i<n; i++) {
int p = (int)(min_element(a,a+n) - a);
int cnt1 = 0, cnt2 = 0;
for (int i=0; i<p; i++) {
if(a[i] <= 1e9) cnt1++;
}
for (int i=p+1; i<n; i++) {
if(a[i] <= 1e9) cnt2++;
}
a[p] = 2e9;
ret += min(cnt1,cnt2);
}
printf("%d",ret);
}
# | 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... |