結果
問題 | No.1972 Modulo Set |
ユーザー |
![]() |
提出日時 | 2022-06-10 21:22:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 509 bytes |
コンパイル時間 | 2,084 ms |
コンパイル使用メモリ | 181,108 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2024-10-05 01:20:07 |
合計ジャッジ時間 | 5,466 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int N;long long M;cin >> N >> M;vector<long long> A(N);for (int i = 0; i < N; i++){cin >> A[i];}set<long long> st;map<long long, int> mp;for (int i = 0; i < N; i++){long long r = A[i] % M;mp[r]++;r = min(r, M - r);st.insert(r);}int ans = 0;for (long long x : st){if (x == 0 || x * 2 == M){ans++;} else {ans += max(mp[x], mp[M - x]);}}cout << ans << endl;}