結果

問題 No.1972 Modulo Set
ユーザー yamake
提出日時 2022-06-10 21:33:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 175,568 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2024-10-05 01:26:14
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<"\n";
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1.1e18;const int inf=1.01e9;
constexpr int MOD=1000000007;
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(a > b){ a = b; return 1; } return 0; }

signed main(){
    lint n,m;cin>>n>>m;
    vector<lint> a(n);
    rep(i,n)cin>>a[i];
    map<lint,lint> mp;
    rep(i,n)mp[a[i]%m]+=1;
    int res=0;
    if(mp[0]>0){
        ++res;
        mp[0]=0;
    }
    for(auto& it:mp){
        int r=m-it.first;
        if(it.first*2==m){
            res+=1;
            continue;
        }
        res+=max(it.second,mp[r]);
        it.second=0;mp[r]=0;
    }
    cout<<res<<"\n";
    return 0;
}
0