結果

問題 No.1972 Modulo Set
ユーザー 👑 NachiaNachia
提出日時 2022-06-10 21:24:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 948 bytes
コンパイル時間 834 ms
コンパイル使用メモリ 91,744 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-27 05:10:05
合計ジャッジ時間 3,095 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 7 ms
6,940 KB
testcase_04 AC 10 ms
6,940 KB
testcase_05 AC 11 ms
6,940 KB
testcase_06 AC 17 ms
6,940 KB
testcase_07 AC 25 ms
6,940 KB
testcase_08 AC 11 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 10 ms
6,940 KB
testcase_11 AC 24 ms
6,944 KB
testcase_12 AC 6 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 4 ms
6,944 KB
testcase_15 AC 30 ms
6,944 KB
testcase_16 AC 34 ms
6,940 KB
testcase_17 AC 11 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 27 ms
6,944 KB
testcase_20 AC 35 ms
6,944 KB
testcase_21 AC 13 ms
6,940 KB
testcase_22 AC 23 ms
6,944 KB
testcase_23 AC 57 ms
8,192 KB
testcase_24 AC 19 ms
6,940 KB
testcase_25 AC 30 ms
6,944 KB
testcase_26 AC 39 ms
6,940 KB
testcase_27 AC 59 ms
8,448 KB
testcase_28 AC 19 ms
6,940 KB
testcase_29 AC 31 ms
6,940 KB
testcase_30 AC 45 ms
7,680 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 39 ms
7,296 KB
testcase_33 AC 71 ms
9,088 KB
testcase_34 AC 68 ms
9,088 KB
testcase_35 AC 71 ms
9,088 KB
testcase_36 AC 67 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <atcoder/modint>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)


const i64 INF = 1001001001001001001;
using modint = atcoder::static_modint<1000000007>;


int main(){
    int N; cin >> N;
    i64 M; cin >> M;
    map<i64, pair<int,int>> A;
    int t = 0;
    int s = 0;
    rep(i,N){
        i64 a; cin >> a;
        a %= M;
        if(a == 0) t = 1;
        else if(a*2 == M) s = 1;
        else{
            if(M-a < a) A[a].first++; else A[M-a].second++;
        }
    }
    for(auto a : A) t += max(a.second.first, a.second.second);
    cout << (t+s) << endl;
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0