結果

問題 No.1972 Modulo Set
ユーザー milanis48663220milanis48663220
提出日時 2022-06-10 21:25:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,815 bytes
コンパイル時間 1,336 ms
コンパイル使用メモリ 126,480 KB
実行使用メモリ 10,108 KB
最終ジャッジ日時 2023-10-21 04:50:10
合計ジャッジ時間 3,893 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 50 ms
6,412 KB
testcase_17 AC 15 ms
4,548 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 39 ms
6,148 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 33 ms
5,896 KB
testcase_23 AC 79 ms
9,052 KB
testcase_24 AC 25 ms
5,684 KB
testcase_25 AC 40 ms
6,732 KB
testcase_26 WA -
testcase_27 AC 85 ms
9,316 KB
testcase_28 AC 25 ms
5,720 KB
testcase_29 AC 41 ms
6,744 KB
testcase_30 AC 60 ms
7,996 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 53 ms
7,484 KB
testcase_33 AC 97 ms
10,108 KB
testcase_34 AC 98 ms
10,108 KB
testcase_35 AC 97 ms
10,108 KB
testcase_36 AC 93 ms
10,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; ll m; cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    map<ll, int> cnt;
    for(ll x: a){
        ll r = x%m;
        if(cnt.count(r)) cnt[r]++;
        else cnt[r] = 1;
    }
    int ans = 0;
    for(auto [x, c]: cnt){
        if(x+x == m){
            ans++;
            continue;
        }
        ll y = m-x;
        if(cnt.count(y) == 0){
            ans += c;
        }else{
            if(x > y) continue;
            ans += max(c, cnt[y]);
        }
    }
    cout << ans << endl;
}
0