#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Correct |
0 ms |
1084 KB |
Output is correct |
4 |
Correct |
0 ms |
1084 KB |
Output is correct |
5 |
Correct |
0 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
0 ms |
1084 KB |
Output is correct |
8 |
Correct |
0 ms |
1084 KB |
Output is correct |
9 |
Correct |
0 ms |
1084 KB |
Output is correct |
10 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Incorrect |
14 ms |
1084 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
1080 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |