結果

問題 No.1972 Modulo Set
ユーザー magstamagsta
提出日時 2021-08-04 16:54:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,265 bytes
コンパイル時間 7,524 ms
コンパイル使用メモリ 232,984 KB
実行使用メモリ 31,420 KB
最終ジャッジ日時 2024-04-15 08:42:50
合計ジャッジ時間 13,047 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 24 ms
6,356 KB
testcase_04 AC 37 ms
7,460 KB
testcase_05 AC 44 ms
8,156 KB
testcase_06 AC 74 ms
10,720 KB
testcase_07 AC 129 ms
17,364 KB
testcase_08 AC 46 ms
8,580 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 37 ms
7,340 KB
testcase_11 AC 116 ms
14,108 KB
testcase_12 AC 17 ms
5,376 KB
testcase_13 AC 9 ms
5,376 KB
testcase_14 AC 10 ms
5,376 KB
testcase_15 AC 137 ms
16,140 KB
testcase_16 AC 154 ms
17,800 KB
testcase_17 AC 44 ms
8,476 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 121 ms
15,832 KB
testcase_20 AC 159 ms
18,424 KB
testcase_21 AC 55 ms
9,424 KB
testcase_22 AC 101 ms
14,520 KB
testcase_23 AC 253 ms
27,176 KB
testcase_24 AC 79 ms
12,872 KB
testcase_25 AC 131 ms
17,872 KB
testcase_26 AC 205 ms
19,892 KB
testcase_27 AC 260 ms
28,264 KB
testcase_28 AC 79 ms
13,128 KB
testcase_29 AC 135 ms
17,860 KB
testcase_30 AC 192 ms
23,124 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 169 ms
21,408 KB
testcase_33 AC 307 ms
31,420 KB
testcase_34 AC 306 ms
31,296 KB
testcase_35 AC 299 ms
31,296 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include "testlib.h"
using namespace std;
#define MOD 998244353

int main() {
    registerValidation();
    long long N = inf.readLong((long long)1, (long long)100000, "N");
    inf.readSpace();
    long long M = inf.readLong((long long)1, (long long)1000000000000, "M");
    inf.readEoln();
    vector<long long> A(N);
    A[0] = inf.readLong((long long)1, (long long)1000000000000, "A1");
    map<long long, long long> Map2;
    Map2[A[0]]++;
    for (int i = 1; i < N; i++) {
        inf.readSpace();
        A[i] = inf.readLong((long long)1, (long long)1000000000000, "A");
        Map2[A[i]]++;
        if (Map2[A[i]] > 1) cout << -1 << endl;
    }
    inf.readEoln();
    inf.readEof();

	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