結果

問題 No.1972 Modulo Set
ユーザー magstamagsta
提出日時 2021-08-04 11:54:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 176,028 KB
実行使用メモリ 19,840 KB
最終ジャッジ日時 2024-04-15 08:42:18
合計ジャッジ時間 6,941 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 18 ms
6,944 KB
testcase_04 AC 25 ms
6,940 KB
testcase_05 AC 28 ms
6,940 KB
testcase_06 AC 46 ms
6,940 KB
testcase_07 AC 71 ms
6,940 KB
testcase_08 AC 30 ms
6,940 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 24 ms
6,944 KB
testcase_11 AC 69 ms
6,940 KB
testcase_12 AC 13 ms
6,940 KB
testcase_13 AC 8 ms
6,940 KB
testcase_14 AC 9 ms
6,944 KB
testcase_15 AC 93 ms
7,552 KB
testcase_16 AC 116 ms
9,344 KB
testcase_17 AC 33 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 98 ms
9,088 KB
testcase_20 AC 120 ms
9,984 KB
testcase_21 AC 41 ms
6,940 KB
testcase_22 AC 78 ms
8,764 KB
testcase_23 AC 199 ms
17,152 KB
testcase_24 AC 62 ms
8,968 KB
testcase_25 AC 103 ms
11,884 KB
testcase_26 AC 134 ms
8,448 KB
testcase_27 AC 214 ms
17,920 KB
testcase_28 AC 63 ms
9,176 KB
testcase_29 AC 103 ms
12,108 KB
testcase_30 AC 155 ms
15,360 KB
testcase_31 AC 7 ms
6,940 KB
testcase_32 AC 137 ms
14,336 KB
testcase_33 AC 248 ms
19,840 KB
testcase_34 AC 245 ms
19,840 KB
testcase_35 AC 242 ms
19,712 KB
testcase_36 AC 243 ms
19,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long N, M; cin >> N >> M;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	map<long long, long long> Map;
	set<long long> Set;
	for (int i = 0; i < N; i++) {
		Map[A[i] % M]++;
		Set.insert(A[i] % M);
	}

	long long count = 0;
	while (!Set.empty()) {
		long long a = *Set.begin();
		Set.erase(Set.begin());
		if (a == 0 || a * 2 == M) {
			count++;
		}
		else {
			count += max(Map[a], Map[M - a]);
			Map[a] = 0;
			Map[M - a] = 0;
		}
	}

	cout << count << endl;
}
0