Submission #992126


Source Code Expand

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, M; cin >> N >> M;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	vector<int> b(100001);
	rep(i, N) b[a[i]]++;
	vector<int> c(M), d(M);
	rep(x, 100001) {
		c[x % M] += b[x];
		d[x % M] += b[x] / 2;
	}
	int ans = 0;
	for (int x = 0; x * 2 <= M; x++) {
		if (x == 0 || x * 2 == M) {
			ans += c[x] / 2;
			continue;
		}
		int y = M - x;
		if (c[x] > c[y]) {
			swap(c[x], c[y]);
			swap(d[x], d[y]);
		}
		ans += c[x] + min(d[y], (c[y] - c[x]) / 2);
	}
	cout << ans << endl;
}

Submission Info

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

Compile Error

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

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 640 KB
01-02.txt AC 13 ms 1024 KB
01-03.txt AC 13 ms 1024 KB
01-04.txt AC 13 ms 1024 KB
01-05.txt AC 13 ms 1024 KB
01-06.txt AC 13 ms 1024 KB
01-07.txt AC 13 ms 1024 KB
01-08.txt AC 13 ms 1024 KB
01-09.txt AC 13 ms 1024 KB
01-10.txt AC 13 ms 1280 KB
01-11.txt AC 14 ms 1792 KB
01-12.txt AC 13 ms 1024 KB
01-13.txt AC 13 ms 1408 KB
01-14.txt AC 13 ms 1024 KB
01-15.txt AC 13 ms 1024 KB
01-16.txt AC 13 ms 1024 KB
01-17.txt AC 13 ms 1024 KB
01-18.txt AC 13 ms 1024 KB
01-19.txt AC 13 ms 1152 KB
01-20.txt AC 14 ms 1792 KB
01-21.txt AC 13 ms 1024 KB
01-22.txt AC 13 ms 1024 KB
01-23.txt AC 13 ms 1024 KB
01-24.txt AC 13 ms 1024 KB
01-25.txt AC 13 ms 1280 KB
01-26.txt AC 14 ms 1792 KB
01-27.txt AC 9 ms 1664 KB
01-28.txt AC 4 ms 1408 KB
01-29.txt AC 4 ms 896 KB
01-30.txt AC 4 ms 1408 KB
sample-01.txt AC 3 ms 640 KB
sample-02.txt AC 3 ms 640 KB