Submission #845972


Source Code Expand

#include<iostream>
#include<algorithm>

using namespace std;

int const N = 1e5 + 41;

int n, a[N], ans, b[N];

int getPos(int v){
	int l = -1;
	int r = n;
	while(r-l>1){
		int m = (l+r);
		if(b[m] <= v){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	if(n == 1){
		printf("%d\n", ans);
		return 0;
	}
	if(n == 2){
		if(a[0] > a[1]){
			++ans;
		}
		printf("%d\n",ans);
		return 0;
	}

	sort(b, b+n);
	for(int i=0;i<n;++i){
		if((i % 2) != getPos(a[i]) % 2){
			++ans;
		} 
	}
	ans /= 2;
	printf("%d\n",ans);




	return 0;
}

Submission Info

Submission Time
Task C - BBuBBBlesort!
User Filyan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 674 Byte
Status TLE
Exec Time 2101 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:27:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 2
AC × 7
TLE × 17
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt TLE 2101 ms 1024 KB
02.txt TLE 2101 ms 1024 KB
03.txt TLE 2101 ms 1024 KB
04.txt TLE 2101 ms 1024 KB
05.txt TLE 2101 ms 1024 KB
06.txt TLE 2101 ms 1024 KB
07.txt TLE 2101 ms 1024 KB
08.txt TLE 2101 ms 1024 KB
09.txt TLE 2101 ms 1024 KB
10.txt TLE 2101 ms 1024 KB
11.txt TLE 2101 ms 1024 KB
12.txt TLE 2101 ms 1024 KB
13.txt TLE 2101 ms 1024 KB
14.txt TLE 2101 ms 1024 KB
15.txt TLE 2101 ms 1024 KB
16.txt TLE 2101 ms 1024 KB
17.txt TLE 2101 ms 1024 KB
18.txt AC 4 ms 256 KB
19.txt AC 4 ms 256 KB
20.txt AC 4 ms 256 KB
21.txt AC 4 ms 256 KB
22.txt AC 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB