結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
platinum
|
| 提出日時 | 2022-06-10 23:39:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 230 ms / 2,000 ms |
| コード長 | 605 bytes |
| コンパイル時間 | 2,122 ms |
| コンパイル使用メモリ | 201,220 KB |
| 最終ジャッジ日時 | 2025-01-29 20:23:11 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
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;
map<LL,int> used;
rep(i,N) mp[A[i]]++;
int ans = 0;
for(auto itr : mp){
LL a1 = itr.first;
if(used[a1]) continue;
LL a2 = (M - a1) % M;
if(a1 == a2) ans++;
else ans += max(mp[a1], mp[a2]);
used[a1] = 1;
used[a2] = 1;
}
cout << ans << endl;
return 0;
}
platinum