結果
問題 |
No.1972 Modulo Set
|
ユーザー |
|
提出日時 | 2022-06-11 00:40:25 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 2,970 ms |
コンパイル使用メモリ | 259,516 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2024-10-05 01:41:01 |
合計ジャッジ時間 | 6,630 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#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) { ll x = a[i]; ll y = m-a[i]; s.insert(min(x, y)); } int ans = 0; for (ll x : s) { if (x == 0 or x*2 == m) ans++; else ans += max(mp[x], mp[m-x]); } cout << ans << '\n'; return 0; }