結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 17 ms
5,376 KB
testcase_04 AC 23 ms
5,376 KB
testcase_05 AC 26 ms
5,376 KB
testcase_06 AC 42 ms
5,376 KB
testcase_07 AC 65 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 8 ms
5,376 KB
testcase_15 AC 77 ms
6,784 KB
testcase_16 AC 89 ms
8,576 KB
testcase_17 AC 28 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 77 ms
8,704 KB
testcase_20 AC 97 ms
9,472 KB
testcase_21 AC 35 ms
5,404 KB
testcase_22 AC 67 ms
8,448 KB
testcase_23 AC 171 ms
16,896 KB
testcase_24 AC 56 ms
8,932 KB
testcase_25 AC 90 ms
11,776 KB
testcase_26 AC 102 ms
7,680 KB
testcase_27 AC 169 ms
17,792 KB
testcase_28 AC 57 ms
9,300 KB
testcase_29 AC 92 ms
12,160 KB
testcase_30 AC 131 ms
15,232 KB
testcase_31 AC 7 ms
5,376 KB
testcase_32 AC 119 ms
14,464 KB
testcase_33 AC 201 ms
19,584 KB
testcase_34 AC 199 ms
19,584 KB
testcase_35 AC 199 ms
19,712 KB
testcase_36 AC 198 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) {
        if (x == 0 or x*2 == m) ans++;
        else ans += max(mp[x], mp[m-x]);
    }
    
    cout << ans << '\n';
    
    return 0;
}
0