結果

問題 No.1972 Modulo Set
ユーザー V_MelvilleV_Melville
提出日時 2022-06-11 00:33:49
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 2,862 ms
コンパイル使用メモリ 258,984 KB
実行使用メモリ 16,744 KB
最終ジャッジ日時 2023-10-21 06:35:08
合計ジャッジ時間 6,406 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 15 ms
4,348 KB
testcase_04 AC 22 ms
4,348 KB
testcase_05 AC 25 ms
4,348 KB
testcase_06 AC 38 ms
4,348 KB
testcase_07 AC 58 ms
4,600 KB
testcase_08 AC 27 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 22 ms
4,348 KB
testcase_11 AC 57 ms
4,600 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 7 ms
4,348 KB
testcase_14 AC 7 ms
4,348 KB
testcase_15 AC 65 ms
6,184 KB
testcase_16 AC 72 ms
7,768 KB
testcase_17 AC 23 ms
4,836 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 61 ms
7,768 KB
testcase_20 AC 73 ms
8,296 KB
testcase_21 AC 28 ms
4,952 KB
testcase_22 AC 53 ms
7,504 KB
testcase_23 AC 138 ms
14,632 KB
testcase_24 AC 43 ms
8,044 KB
testcase_25 AC 73 ms
10,408 KB
testcase_26 AC 85 ms
6,976 KB
testcase_27 AC 137 ms
15,160 KB
testcase_28 AC 46 ms
8,296 KB
testcase_29 AC 68 ms
10,672 KB
testcase_30 AC 93 ms
13,312 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 WA -
testcase_33 AC 151 ms
16,744 KB
testcase_34 AC 143 ms
16,744 KB
testcase_35 AC 149 ms
16,744 KB
testcase_36 AC 150 ms
16,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::min;
using std::max;
using std::set;
using std::map;
using std::vector;
using ll = long long;

int main() {
    int n; 
    ll m;
    cin >> n >> m;
    
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] %= m;
    
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    
    set<int> s;
    rep(i, n) {
        int x = a[i];
        int y = m-a[i];
        s.insert(min(x, y));
    }
    
    ll ans = 0;
    for (int x : s) {
        int y = m-x;
        if (x == 0 or x == y) ans++;
        else ans += max(mp[x], mp[y]);
    }
    
    cout << ans << '\n';
    
    return 0;
}
0