結果

問題 No.1972 Modulo Set
ユーザー platinumplatinum
提出日時 2022-06-10 23:36:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 208,412 KB
最終ジャッジ日時 2025-01-29 20:22:53
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

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;
    map<int,int> used;
    rep(i,N) mp[A[i]]++;
    int ans = 0;
    for(auto itr : mp){
        LL a1 = itr.first;
        if(used[a1]) continue;
        LL a2 = (M - a1) % M;
        if(a1 == a2) ans++;
        else ans += max(mp[a1], mp[a2]);
        used[a1] = 1;
        used[a2] = 1;
    }
    cout << ans << endl;
    
    return 0;
}
0