結果

問題 No.1972 Modulo Set
ユーザー asaringoasaringo
提出日時 2022-06-10 21:47:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 993 bytes
コンパイル時間 2,489 ms
コンパイル使用メモリ 207,340 KB
実行使用メモリ 24,192 KB
最終ジャッジ日時 2024-04-15 08:49:27
合計ジャッジ時間 6,142 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 10 ms
6,940 KB
testcase_04 AC 12 ms
6,944 KB
testcase_05 AC 12 ms
6,940 KB
testcase_06 AC 21 ms
6,944 KB
testcase_07 AC 33 ms
6,940 KB
testcase_08 AC 13 ms
6,940 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 11 ms
6,940 KB
testcase_11 AC 32 ms
6,940 KB
testcase_12 AC 8 ms
6,940 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 7 ms
6,940 KB
testcase_15 AC 54 ms
7,680 KB
testcase_16 AC 73 ms
10,112 KB
testcase_17 AC 21 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 64 ms
10,240 KB
testcase_20 AC 75 ms
11,136 KB
testcase_21 AC 23 ms
6,940 KB
testcase_22 AC 59 ms
9,856 KB
testcase_23 AC 159 ms
20,736 KB
testcase_24 AC 56 ms
10,496 KB
testcase_25 AC 86 ms
14,208 KB
testcase_26 AC 71 ms
8,832 KB
testcase_27 AC 168 ms
21,888 KB
testcase_28 AC 57 ms
11,008 KB
testcase_29 AC 96 ms
14,592 KB
testcase_30 AC 136 ms
18,688 KB
testcase_31 AC 7 ms
6,944 KB
testcase_32 AC 126 ms
17,280 KB
testcase_33 AC 187 ms
24,064 KB
testcase_34 AC 188 ms
24,192 KB
testcase_35 AC 186 ms
23,936 KB
testcase_36 AC 184 ms
23,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

ll n , m ;
ll A[101010] ;
map<ll,ll> mp ;

int main(){
    fast_input_output
    cin >> n >> m ;
    rep(i,n) cin >> A[i] , mp[A[i] % m]++ ;
    int res = 0 ;
    set<ll> st ;
    for(auto it : mp){
        ll a = it.first , c = it.second ;
        if(st.count(a) == 1 || st.count(m-a) == 1) continue;
        st.insert(a) ;
        st.insert(m-a) ;
        if(a == 0) res++ ;
        else if(a + a == m) res++ ;
        else res += max(mp[m-a],mp[a]) ;
    }
    cout << res << endl ;
}
0