結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2022-06-10 22:36:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 565 bytes |
| コンパイル時間 | 2,031 ms |
| コンパイル使用メモリ | 203,140 KB |
| 最終ジャッジ日時 | 2025-01-29 20:06:40 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,m;
cin>>n>>m;
vector<ll> A(n);
rep(i,n) cin>>A[i];
map<ll,ll> M;
rep(i,n) M[A[i]%m]++;
ll ans=0;
if(M[0]>0) ans++;
if(m%2==0 && M[m/2]>0) ans++;
for(auto [a,b]:M){
if(a==0) continue;
if(m%2==0 && a==m/2) continue;
ans+=max(M[a],M[m-a]);
M[a]=0,M[m-a]=0;
}
cout<<ans<<endl;
return 0;
}
umezo