結果

問題 No.1972 Modulo Set
ユーザー 👑 NachiaNachia
提出日時 2024-04-18 02:43:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 82,712 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-04-18 02:43:14
合計ジャッジ時間 2,862 ms
ジャッジサーバーID
(参考情報)
judge5 / 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 7 ms
5,376 KB
testcase_04 AC 10 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 16 ms
5,376 KB
testcase_07 AC 25 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 25 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 29 ms
5,376 KB
testcase_16 AC 33 ms
5,376 KB
testcase_17 AC 11 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 27 ms
5,376 KB
testcase_20 AC 33 ms
5,632 KB
testcase_21 AC 13 ms
5,376 KB
testcase_22 AC 23 ms
5,376 KB
testcase_23 AC 53 ms
8,320 KB
testcase_24 AC 21 ms
5,376 KB
testcase_25 AC 31 ms
6,528 KB
testcase_26 AC 40 ms
5,376 KB
testcase_27 AC 53 ms
8,448 KB
testcase_28 AC 19 ms
5,632 KB
testcase_29 AC 30 ms
6,528 KB
testcase_30 AC 41 ms
7,808 KB
testcase_31 AC 4 ms
5,376 KB
testcase_32 AC 36 ms
7,424 KB
testcase_33 AC 70 ms
9,088 KB
testcase_34 AC 64 ms
9,216 KB
testcase_35 AC 62 ms
9,216 KB
testcase_36 AC 60 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <utility>
#define rep(i,n) for(int i=0; i<int(n); i++)
using i64 = long long;
using namespace std;

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    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;
}
0