結果
問題 |
No.1972 Modulo Set
|
ユーザー |
![]() |
提出日時 | 2024-06-17 16:29:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 167 ms / 2,000 ms |
コード長 | 832 bytes |
コンパイル時間 | 2,183 ms |
コンパイル使用メモリ | 206,800 KB |
最終ジャッジ日時 | 2025-02-21 23:06:25 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; long long m; cin >> n >> m; map<long long, int> cnt; for (int i = 0; i < n; i++) { long long x; cin >> x; cnt[x % m]++; } set<long long> vis; int ans = 0; for (auto [k, v] : cnt) { if (vis.find(k) != vis.end()) continue; if (k == 0) { ans++; } else if (2 * k == m) { ans++; } else { long long x = m - k; if (cnt.find(x) != cnt.end()) { ans += max(v, cnt[x]); } else { ans += v; } vis.insert(x); } vis.insert(k); } cout << ans << endl; }