結果
問題 | No.1972 Modulo Set |
ユーザー |
👑 ![]() |
提出日時 | 2022-06-10 22:02:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 1,153 bytes |
コンパイル時間 | 4,230 ms |
コンパイル使用メモリ | 235,792 KB |
実行使用メモリ | 15,360 KB |
最終ジャッジ日時 | 2024-10-05 01:31:46 |
合計ジャッジ時間 | 6,357 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define repr(i, n) for (int i = (int)(n); i >= 0; i--)#define all(v) v.begin(), v.end()#define mod1 1000000007#define mod2 998244353typedef long long ll;int main(){ll N, M;cin >> N >> M;vector<ll> A(N);rep(i,N) cin >> A[i];map<ll,ll> mp;for (ll i = 0; i < N; i++){mp[A[i] % M]++;}ll ans = 0;for (auto itr = mp.begin(); itr != mp.end(); itr++){if (itr->first == 0){ans += min(1LL, itr->second);}else{if (M % 2 == 0 && itr->first == M / 2){ans += min(1LL, itr->second);}else{if (mp[M - itr->first] == 0){ans += (itr->second);}else{if (itr->first > M / 2) continue;else ans += max(itr->second, mp[M - (itr->first)]);}}}//cout << ans << endl;}cout << ans << endl;}