結果
問題 |
No.1972 Modulo Set
|
ユーザー |
![]() |
提出日時 | 2022-06-11 02:20:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 590 ms / 2,000 ms |
コード長 | 773 bytes |
コンパイル時間 | 1,416 ms |
コンパイル使用メモリ | 174,796 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2024-10-05 01:42:45 |
合計ジャッジ時間 | 9,254 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2022.06.11 02:20:52 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n;cin >> n; ll m;cin >> m; map<ll,int> mp; for (int i = 0; i < n; i++) { ll a;cin >> a; mp[a%m]++; } int ans = 0; for (auto p : mp) { if (p.first == 0) continue; if (mp.find(m-p.first) != mp.end()) { if (p.first>=m-p.first) continue; ans += max(p.second,mp[m-p.first]); } else { ans += p.second; } cerr << ans << " " << p.first << endl; } if (mp.find(0) != mp.end()) ans++; if (m%2==0&&mp.find(m/2)!=mp.end()) ans++; cout << ans << endl; return 0; }