結果

問題 No.1972 Modulo Set
ユーザー V_MelvilleV_Melville
提出日時 2022-06-11 00:43:53
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 4,332 ms
コンパイル使用メモリ 284,608 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-15 08:56:38
合計ジャッジ時間 7,762 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 16 ms
5,376 KB
testcase_04 AC 22 ms
5,376 KB
testcase_05 AC 26 ms
5,376 KB
testcase_06 AC 43 ms
5,376 KB
testcase_07 AC 63 ms
5,376 KB
testcase_08 AC 29 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 24 ms
5,376 KB
testcase_11 AC 62 ms
5,376 KB
testcase_12 AC 11 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 76 ms
6,912 KB
testcase_16 AC 89 ms
8,448 KB
testcase_17 AC 28 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 75 ms
8,704 KB
testcase_20 AC 92 ms
9,472 KB
testcase_21 AC 34 ms
5,376 KB
testcase_22 AC 65 ms
8,568 KB
testcase_23 AC 161 ms
16,896 KB
testcase_24 AC 55 ms
9,064 KB
testcase_25 AC 90 ms
11,940 KB
testcase_26 AC 104 ms
7,808 KB
testcase_27 AC 166 ms
17,664 KB
testcase_28 AC 56 ms
9,296 KB
testcase_29 AC 88 ms
12,160 KB
testcase_30 AC 127 ms
15,232 KB
testcase_31 AC 7 ms
5,376 KB
testcase_32 AC 116 ms
14,208 KB
testcase_33 AC 198 ms
19,712 KB
testcase_34 AC 195 ms
19,584 KB
testcase_35 AC 193 ms
19,584 KB
testcase_36 AC 194 ms
19,584 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<ll, int> mp;
    rep(i, n) mp[a[i]]++;
    
    set<ll> s;
    rep(i, n) {
        ll x = a[i];
        ll y = m-a[i];
        s.insert(min(x, y));
    }
    
    int ans = 0;
    for (ll x : s) {
        ll y = m-x;
        if (x == 0 or x == y) ans++;
        else ans += max(mp[x], mp[y]);
    }
    
    cout << ans << '\n';
    
    return 0;
}
0