結果

問題 No.1972 Modulo Set
ユーザー narahatonarahato
提出日時 2022-06-10 21:48:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 3,094 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 123,276 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-15 08:50:05
合計ジャッジ時間 5,370 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 15 ms
5,376 KB
testcase_04 AC 22 ms
5,376 KB
testcase_05 AC 25 ms
5,376 KB
testcase_06 AC 43 ms
5,376 KB
testcase_07 AC 63 ms
5,376 KB
testcase_08 AC 29 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 22 ms
5,376 KB
testcase_11 AC 59 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 70 ms
6,016 KB
testcase_16 AC 80 ms
6,912 KB
testcase_17 AC 27 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 65 ms
6,656 KB
testcase_20 AC 78 ms
7,296 KB
testcase_21 AC 29 ms
5,376 KB
testcase_22 AC 53 ms
6,528 KB
testcase_23 AC 134 ms
11,136 KB
testcase_24 AC 42 ms
6,772 KB
testcase_25 AC 72 ms
8,192 KB
testcase_26 AC 92 ms
6,784 KB
testcase_27 AC 137 ms
11,520 KB
testcase_28 AC 43 ms
6,740 KB
testcase_29 AC 72 ms
8,448 KB
testcase_30 AC 103 ms
10,112 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 AC 89 ms
9,856 KB
testcase_33 AC 162 ms
12,672 KB
testcase_34 AC 164 ms
12,672 KB
testcase_35 AC 160 ms
12,800 KB
testcase_36 AC 168 ms
12,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<numeric>
#include<set>
#include<deque>
#include<algorithm>
#include<queue>
#include<math.h>
#include<tuple>
#include<functional>
#include<limits>
#include<map>
#include<stack>
#include<string>
#include<stdio.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,a,n) for(int i=(int) a;i<(int) n;i++)
#define ALL(a)  a.begin(),a.end()
#define Upper(a,n) upper_bound(((vector<ll>)a).begin(), (a).end(),(int) n) - a.begin();
#define Lower(a,n) lower_bound(((vector<ll>)a).begin(), (a).end(),(int) n) - a.begin();
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll, ll> PLL;
typedef pair<int, int> PII;


long long INF = 9223372036854775807;
int dx[4] = { 0,1,0,-1 }; int dy[4] = { 1,0,-1,0 };
string EIKO = "abcdefghijklmnopqrstuvwxyz";

template<typename T>
T gcd(T  a, T b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}

ll Pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n == 1) return a;
	if (n % 2 == 1) return (a * Pow(a, n - 1));
	ll t = Pow(a, n / 2);
	return (t * t);
}
ll U = Pow(10, 9) + 7;
template<typename T>
ll kuraiwa(T n) {
	int x = 0; ll y = 0;
	while (n != 0)
	{
		y += (n % 10);
		n /= 10;
		x++;
	}
	return y;
}

template<typename T>
long long modPow(T a, T n, T p) {
	if (n == 0) return 1;
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

template<typename T>
vector<int> bittify(T n) {
	vector<int> a;
	while (n != 0) {
		int s = n % 2;
		a.push_back(s);
		n /= 2;
	}
	return a;
}

template<typename T>
ll sinsuu(T xyz, T yzx, T abc) {
	ll b = 0, h = 0;
	while (abc != 0) {
		int g = abc % 10;
		abc /= 10;
		b += g * Pow(xyz, h);
		h++;
	}
	if (yzx == 10) {
		return b;
	}
	ll c = 0; h = 0;
	while (b != 0) {
		c += (b % yzx) * Pow(10, h);
		h++;
	}
	return c;
}


template<typename T>
bool sosuu(T x) {
	for (int i = 2; i * i <= x;i++) {
		if (x % i == 0)
			return false;
	}
	return true;
}

template<typename T>
vector<ll> bunnkai(T x) {
	vector<ll> a;
	ll n = 2;
	while (x != 1) {
		while (x % n == 0) {
			a.push_back(n);
			x /= n;
			if (x == 1)
				break;
		}
		if (n >= sqrt(x))
			break;
		n++;
	}
	if (x != 1)
		a.push_back(x);
	return a;
}

template<typename T>
vector<ll> yakusuu(T x) {
	vector<ll> a;
	for (ll i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			a.push_back(i);
			if (i != x / i) {
				a.push_back(x / i);
			}
		}
	}
	sort(ALL(a));
	return a;
}


template<typename T>
unsigned int factorial(T n) {
	unsigned int ans;

	ans = 1;
	for (unsigned int i = 2; i <= n; i++) {
		ans *= i;
	}

	return ans;
}

int main() {
	ll n, m; cin >> n >> m;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	map<ll, ll> S;
	rep(i, n) {
		a[i] %= m;
		S[a[i]]++;
	}
	int ans = n;
	for (auto i : S) {
        if (i.first == 0 and i.second >= 2)
			ans -= i.second - 1;

		else if (i.first * 2 < m) {
			if (S[m - i.first] > 0) {
				ans -= min(i.second, S[m - i.first]);
			}
		}
		else if (i.first * 2 == m)
			ans -= i.second - 1;
		
	}
	cout << ans << endl;
}
0