結果
問題 | No.1972 Modulo Set |
ユーザー |
![]() |
提出日時 | 2022-11-18 15:42:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 793 bytes |
コンパイル時間 | 1,548 ms |
コンパイル使用メモリ | 178,428 KB |
実行使用メモリ | 9,984 KB |
最終ジャッジ日時 | 2024-09-19 21:44:32 |
合計ジャッジ時間 | 4,149 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; int main() { lint n, m; cin >> n >> m; vector<lint> vec(n); for (int i = 0; i < n; i++) cin >> vec[i]; map<lint, lint> ma; map<lint, lint> ma2; for (int i = 0; i < n; i++) { if (vec[i]%m == 0) ma2[vec[i]]++; else ma[vec[i]%m]++; } lint ans = 0; for (auto pa : ma) { lint x = pa.first; lint y = pa.second; if (m-x == x) ans++; else if (ma.count(m-x)) { if (m-x > x) ans += max(y, ma.at(m-x)); } else ans += y; /* if (m-x == x) ans++; else if (m-x < x) break; else { if (ma.count(m-x)) { ans += max(ma.at(m-x), y); } } //*/ } lint high = 0; for (auto x : ma2) high = max(high, x.second); cout << ans+high << endl; }