結果

問題 No.1972 Modulo Set
ユーザー Maffy-0Maffy-0
提出日時 2022-06-18 11:37:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 171,424 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-04-18 05:45:11
合計ジャッジ時間 5,377 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 15 ms
5,376 KB
testcase_04 AC 21 ms
5,376 KB
testcase_05 AC 24 ms
5,376 KB
testcase_06 AC 39 ms
5,376 KB
testcase_07 AC 59 ms
5,376 KB
testcase_08 AC 27 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 22 ms
5,376 KB
testcase_11 AC 57 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 69 ms
5,504 KB
testcase_16 AC 77 ms
6,272 KB
testcase_17 AC 24 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 61 ms
5,888 KB
testcase_20 AC 76 ms
6,528 KB
testcase_21 AC 31 ms
5,376 KB
testcase_22 AC 50 ms
5,760 KB
testcase_23 AC 104 ms
8,576 KB
testcase_24 AC 36 ms
5,504 KB
testcase_25 AC 59 ms
6,656 KB
testcase_26 AC 93 ms
5,888 KB
testcase_27 AC 112 ms
8,832 KB
testcase_28 AC 35 ms
5,632 KB
testcase_29 AC 56 ms
6,528 KB
testcase_30 AC 82 ms
7,808 KB
testcase_31 AC 5 ms
5,376 KB
testcase_32 AC 73 ms
7,296 KB
testcase_33 AC 134 ms
9,472 KB
testcase_34 AC 130 ms
9,600 KB
testcase_35 AC 135 ms
9,600 KB
testcase_36 AC 134 ms
9,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using Graph = vector<vector<int>>;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (ll i = s; i < (t); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void solve(){
    ll n,m;
    cin >> n >> m;
    map<ll,ll> mp;
    rep(i,n){
        ll a;
        cin >> a;
        mp[a%m]++;
    }
    ll ans = 0;
    for(auto x : mp){
        if(2*x.first%m == 0){
            ans++;
            continue;
        }
        if(!mp.count((m-x.first)%m)){
            ans += x.second;
            continue;
        }
        ll y = (m-x.first)%m;
        if(x.first > y) continue;
        ans += max(mp[x.first],mp[y]); 
    }
    cout << ans << endl;
}

int main(void){
    solve();
    return 0;
}
0