結果

問題 No.1972 Modulo Set
ユーザー RuiRui
提出日時 2022-11-18 20:17:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 4,721 ms
コンパイル使用メモリ 244,408 KB
実行使用メモリ 15,064 KB
最終ジャッジ日時 2023-10-20 05:26:08
合計ジャッジ時間 9,376 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 14 ms
4,348 KB
testcase_04 AC 21 ms
4,348 KB
testcase_05 WA -
testcase_06 AC 37 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 5 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 57 ms
4,440 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 7 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 71 ms
6,592 KB
testcase_16 AC 81 ms
7,816 KB
testcase_17 AC 26 ms
4,972 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 66 ms
7,632 KB
testcase_20 AC 83 ms
8,624 KB
testcase_21 AC 31 ms
5,136 KB
testcase_22 AC 56 ms
7,400 KB
testcase_23 AC 124 ms
13,108 KB
testcase_24 AC 40 ms
7,460 KB
testcase_25 AC 67 ms
9,292 KB
testcase_26 WA -
testcase_27 AC 121 ms
13,600 KB
testcase_28 AC 41 ms
7,492 KB
testcase_29 AC 64 ms
9,568 KB
testcase_30 AC 97 ms
11,736 KB
testcase_31 AC 6 ms
4,348 KB
testcase_32 AC 86 ms
11,104 KB
testcase_33 AC 144 ms
15,064 KB
testcase_34 AC 146 ms
15,060 KB
testcase_35 AC 148 ms
15,060 KB
testcase_36 AC 149 ms
15,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef modint998244353 mint;
const int MOD = 1000000007;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1 << 30;
const ll INF = 1LL << 60;
const int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
    ll n, m;
    cin >> n >> m;

    if(m == 1){
        cout << 1 << endl;
        return 0;
    }

    map<ll, int> mp;
    rep(i, n){
        ll a;
        cin >> a;
        mp[a % m]++;
    }

    vector<pair<int, ll>> vec;
    for(auto it = mp.begin(); it != mp.end(); it++){
        vec.push_back({it->second, it->first});
    }

    sort(all(vec));
    reverse(all(vec));

    int ans = 0;
    set<ll> st;
    rep(i, vec.size()){
        if(vec[i].second == 0) ans++;
        else if(!st.count(m - vec[i].second)){
            ans += vec[i].first;
            st.insert(vec[i].second);
        }
    }

    cout << ans << endl;

    return 0;
}
0