結果
問題 | No.1972 Modulo Set |
ユーザー |
|
提出日時 | 2022-06-11 00:36:25 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 709 bytes |
コンパイル時間 | 3,152 ms |
コンパイル使用メモリ | 259,800 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-09-21 07:47:14 |
合計ジャッジ時間 | 6,989 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 WA * 5 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int i = 0; i < (n); ++i)using std::cin;using std::cout;using std::min;using std::max;using std::set;using std::map;using std::vector;using ll = long long;int main() {int n;ll m;cin >> n >> m;vector<ll> a(n);rep(i, n) cin >> a[i];rep(i, n) a[i] %= m;map<ll, int> mp;rep(i, n) mp[a[i]]++;set<ll> s;rep(i, n) {int x = a[i];int y = m-a[i];s.insert(min(x, y));}ll ans = 0;for (ll x : s) {int y = m-x;if (x == 0 or x == y) ans++;else ans += max(mp[x], mp[y]);}cout << ans << '\n';return 0;}