Submission #845428


Source Code Expand

Copy
/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 233031;

using namespace std;

int n, ar[N];
vector<int > v[5];

multiset<int> S[10];
multiset<int>::iterator it;
int bad[1000];

int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> ar[i];
		v[i % 2].push_back(ar[i]);
	}

	for (int i = 0; i <= 1; i++)
	{
		sort(v[i].begin(), v[i].end());
		reverse(v[i].begin(), v[i].end());
	}
	for (int i = 1; i <= n; i++)
	{
		ar[i] = v[i % 2].back();
		v[i % 2].pop_back();
	}

	for (int i = 1; i <= n; i++)
	{
		S[i % 2].insert(ar[i]);
	}

	sort(ar + 1, ar + n + 1);
	for (int i = 1; i <= n; i++)
	{
		it = S[i % 2].lower_bound(ar[i]);
		if (it == S[i % 2].end())
		{
			bad[i % 2]++;
			continue;
		}
		int val = (*it);
		if (val != ar[i])
		{
			bad[i % 2]++;
			continue;
		}
		S[i % 2].erase(it);
	}

	cout << max(bad[0], bad[1]) << endl;

	cin.get(); cin.get();
	return 0;
}

Submission Info

Submission Time
Task C - BBuBBBlesort!
User LeBron
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1781 Byte
Status AC
Exec Time 91 ms
Memory 5756 KB

Compile Error

./Main.cpp:32:0: warning: "M_PI" redefined
 #define M_PI 3.141592653589793
 ^
In file included from /usr/include/c++/5/cmath:44:0,
                 from /usr/include/c++/5/complex:44,
                 from ./Main.cpp:9:
/usr/include/math.h:372:0: note: this is the location of the previous definition
 # define M_PI  3.14159265358979323846 /* pi */
 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 24
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 AC 91 ms 5756 KB
02.txt AC 89 ms 5756 KB
03.txt AC 88 ms 5756 KB
04.txt AC 89 ms 5756 KB
05.txt AC 84 ms 5756 KB
06.txt AC 86 ms 5756 KB
07.txt AC 86 ms 5756 KB
08.txt AC 68 ms 5756 KB
09.txt AC 69 ms 5756 KB
10.txt AC 75 ms 5756 KB
11.txt AC 68 ms 5756 KB
12.txt AC 75 ms 5756 KB
13.txt AC 75 ms 5756 KB
14.txt AC 76 ms 5756 KB
15.txt AC 78 ms 5756 KB
16.txt AC 82 ms 5756 KB
17.txt AC 76 ms 5756 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