結果

問題 No.1972 Modulo Set
ユーザー V_MelvilleV_Melville
提出日時 2022-06-11 03:21:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 4,493 ms
コンパイル使用メモリ 284,588 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-15 08:56:57
合計ジャッジ時間 7,136 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 10 ms
5,376 KB
testcase_04 AC 12 ms
5,376 KB
testcase_05 AC 14 ms
5,376 KB
testcase_06 AC 22 ms
5,376 KB
testcase_07 AC 35 ms
5,376 KB
testcase_08 AC 14 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 34 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 51 ms
6,912 KB
testcase_16 AC 62 ms
8,576 KB
testcase_17 AC 20 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 53 ms
8,576 KB
testcase_20 AC 67 ms
9,344 KB
testcase_21 AC 22 ms
5,376 KB
testcase_22 AC 48 ms
8,448 KB
testcase_23 AC 130 ms
17,024 KB
testcase_24 AC 44 ms
9,080 KB
testcase_25 AC 73 ms
11,776 KB
testcase_26 AC 69 ms
7,808 KB
testcase_27 AC 139 ms
17,664 KB
testcase_28 AC 44 ms
9,196 KB
testcase_29 AC 72 ms
12,128 KB
testcase_30 AC 105 ms
15,232 KB
testcase_31 AC 5 ms
5,376 KB
testcase_32 AC 93 ms
14,208 KB
testcase_33 AC 161 ms
19,584 KB
testcase_34 AC 159 ms
19,712 KB
testcase_35 AC 159 ms
19,712 KB
testcase_36 AC 159 ms
19,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region Macros
#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() {
    cin.tie(nullptr) -> sync_with_stdio(false);
    
    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