結果

問題 No.1972 Modulo Set
ユーザー magstamagsta
提出日時 2022-06-06 14:12:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,265 bytes
コンパイル時間 8,899 ms
コンパイル使用メモリ 234,644 KB
実行使用メモリ 33,264 KB
最終ジャッジ日時 2024-04-15 08:43:25
合計ジャッジ時間 13,210 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,812 KB
testcase_03 AC 24 ms
6,816 KB
testcase_04 AC 37 ms
7,328 KB
testcase_05 AC 44 ms
8,032 KB
testcase_06 AC 73 ms
10,972 KB
testcase_07 AC 122 ms
18,004 KB
testcase_08 AC 50 ms
8,460 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 38 ms
7,472 KB
testcase_11 AC 117 ms
14,132 KB
testcase_12 AC 17 ms
6,940 KB
testcase_13 AC 9 ms
6,940 KB
testcase_14 AC 10 ms
6,940 KB
testcase_15 AC 140 ms
16,032 KB
testcase_16 AC 159 ms
17,992 KB
testcase_17 AC 46 ms
8,532 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 125 ms
15,852 KB
testcase_20 AC 165 ms
18,564 KB
testcase_21 AC 55 ms
9,428 KB
testcase_22 AC 106 ms
15,092 KB
testcase_23 AC 248 ms
27,468 KB
testcase_24 AC 77 ms
13,028 KB
testcase_25 AC 139 ms
17,892 KB
testcase_26 AC 203 ms
21,176 KB
testcase_27 AC 261 ms
28,872 KB
testcase_28 AC 78 ms
13,132 KB
testcase_29 AC 129 ms
18,336 KB
testcase_30 AC 193 ms
23,076 KB
testcase_31 AC 8 ms
6,944 KB
testcase_32 AC 173 ms
21,384 KB
testcase_33 AC 307 ms
31,688 KB
testcase_34 AC 305 ms
31,588 KB
testcase_35 AC 308 ms
32,556 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