結果

問題 No.1972 Modulo Set
ユーザー magstamagsta
提出日時 2022-06-06 14:12:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,264 bytes
コンパイル時間 6,169 ms
コンパイル使用メモリ 214,100 KB
実行使用メモリ 4,684 KB
最終ジャッジ日時 2023-10-21 03:34:39
合計ジャッジ時間 7,640 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
権限があれば一括ダウンロードができます

ソースコード

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)100000000000, "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