結果

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

ソースコード

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