結果

問題 No.1972 Modulo Set
ユーザー yamakeyamake
提出日時 2022-06-10 21:33:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 170,872 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-04-15 08:47:02
合計ジャッジ時間 6,041 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 16 ms
5,376 KB
testcase_04 AC 22 ms
5,376 KB
testcase_05 AC 25 ms
5,376 KB
testcase_06 AC 38 ms
5,376 KB
testcase_07 AC 61 ms
5,376 KB
testcase_08 AC 28 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 22 ms
5,376 KB
testcase_11 AC 61 ms
5,376 KB
testcase_12 AC 11 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 77 ms
6,016 KB
testcase_16 AC 99 ms
7,168 KB
testcase_17 AC 25 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 77 ms
7,168 KB
testcase_20 AC 93 ms
7,808 KB
testcase_21 AC 32 ms
5,376 KB
testcase_22 AC 59 ms
7,040 KB
testcase_23 AC 151 ms
13,568 KB
testcase_24 AC 52 ms
7,588 KB
testcase_25 AC 83 ms
9,472 KB
testcase_26 AC 108 ms
6,784 KB
testcase_27 AC 168 ms
14,080 KB
testcase_28 AC 52 ms
7,632 KB
testcase_29 AC 90 ms
9,932 KB
testcase_30 AC 139 ms
12,160 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 AC 128 ms
11,292 KB
testcase_33 AC 189 ms
15,488 KB
testcase_34 AC 186 ms
15,488 KB
testcase_35 AC 193 ms
15,360 KB
testcase_36 AC 174 ms
15,360 KB
権限があれば一括ダウンロードができます

ソースコード

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