結果

問題 No.1972 Modulo Set
ユーザー magstamagsta
提出日時 2022-06-06 14:23:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,203 bytes
コンパイル時間 5,834 ms
コンパイル使用メモリ 214,068 KB
実行使用メモリ 26,480 KB
最終ジャッジ日時 2023-10-21 03:35:15
合計ジャッジ時間 11,249 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 5 ms
4,372 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 7 ms
4,876 KB
testcase_14 AC 8 ms
4,956 KB
testcase_15 WA -
testcase_16 AC 113 ms
14,028 KB
testcase_17 AC 36 ms
7,292 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 92 ms
12,972 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 75 ms
11,960 KB
testcase_23 AC 187 ms
22,740 KB
testcase_24 AC 61 ms
11,388 KB
testcase_25 AC 98 ms
15,348 KB
testcase_26 WA -
testcase_27 AC 186 ms
23,796 KB
testcase_28 AC 62 ms
11,572 KB
testcase_29 AC 93 ms
15,400 KB
testcase_30 AC 138 ms
19,836 KB
testcase_31 AC 7 ms
4,752 KB
testcase_32 AC 129 ms
18,252 KB
testcase_33 AC 230 ms
26,436 KB
testcase_34 AC 220 ms
26,172 KB
testcase_35 AC 234 ms
26,472 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());
		count += max(Map[a], Map[M - a]);
		Map[a] = 0;
		Map[M - a] = 0;
	}

	cout << count << endl;
}
0