Submission #992215


Source Code Expand

/*
*/

#define _CRT_SECURE_NO_WARNINGS

#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 <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 337

using namespace std;

const int INF = 1e9;
const int N = 201231;

int n, m, cnt[N];
int odds[N];
int ans;
int evens[N];

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/input.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}

	for (int i = 1; i <= 100000; i++)
	{
		if (cnt[i] % 2)
		{
			odds[i%m]++;
		}
		evens[i%m] += cnt[i] - cnt[i] % 2;
	}

	for (int i = 0; i < m; i++)
	{
		int othr = m - i;
		othr %= m;
		if (othr < i)
			continue;

		if (i != othr)
		{
			int here = min(odds[i], odds[othr]);
			ans += here;
			odds[i] -= here;
			odds[othr] -= here;
		}
		else
			ans += odds[i] / 2,
			odds[i] %= 2;
	}

	for (int i = 0; i < m; i++)
	{
		int othr = m - i;
		othr %= m;
		int can_add = min(odds[i], evens[othr]);
		can_add -= can_add % 2;
		ans += can_add;
		odds[i] -= can_add;
		evens[othr] -= can_add;
	}

	for (int i = 0; i <m; i++)
		ans += evens[i] / 2;

	cout << ans << endl;

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

Submission Info

Submission Time
Task D - Pair Cards
User LeBron
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1869 Byte
Status AC
Exec Time 14 ms
Memory 1408 KB

Compile Error

./Main.cpp:35: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 700 / 700
Status
AC × 2
AC × 32
Set Name Test Cases
sample sample-01.txt, sample-02.txt
all sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt
Case Name Status Exec Time Memory
01-01.txt AC 3 ms 256 KB
01-02.txt AC 12 ms 640 KB
01-03.txt AC 12 ms 640 KB
01-04.txt AC 12 ms 640 KB
01-05.txt AC 12 ms 640 KB
01-06.txt AC 12 ms 640 KB
01-07.txt AC 12 ms 640 KB
01-08.txt AC 12 ms 640 KB
01-09.txt AC 12 ms 640 KB
01-10.txt AC 12 ms 1152 KB
01-11.txt AC 14 ms 1408 KB
01-12.txt AC 11 ms 256 KB
01-13.txt AC 12 ms 640 KB
01-14.txt AC 11 ms 640 KB
01-15.txt AC 11 ms 640 KB
01-16.txt AC 11 ms 640 KB
01-17.txt AC 11 ms 768 KB
01-18.txt AC 12 ms 640 KB
01-19.txt AC 12 ms 768 KB
01-20.txt AC 13 ms 1408 KB
01-21.txt AC 11 ms 640 KB
01-22.txt AC 11 ms 640 KB
01-23.txt AC 12 ms 640 KB
01-24.txt AC 11 ms 640 KB
01-25.txt AC 12 ms 896 KB
01-26.txt AC 13 ms 1408 KB
01-27.txt AC 9 ms 1280 KB
01-28.txt AC 5 ms 1408 KB
01-29.txt AC 4 ms 1152 KB
01-30.txt AC 5 ms 1024 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt AC 3 ms 256 KB