結果
問題 | No.1972 Modulo Set |
ユーザー |
|
提出日時 | 2022-06-11 03:06:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 466 bytes |
コンパイル時間 | 1,663 ms |
コンパイル使用メモリ | 174,668 KB |
実行使用メモリ | 14,848 KB |
最終ジャッジ日時 | 2024-10-05 01:42:20 |
合計ジャッジ時間 | 4,209 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); long long N,M; cin>>N>>M; map<long long,int>cnt; for(int i=0;i<N;i++){ long long A; cin>>A; cnt[A%M]+=1; cnt[(M-A%M)%M]+=0; } int ans=0; for(auto i:cnt){ if(i.first>M/2)continue; if(i.first*2==M||i.first==0){ ans+=min(1,i.second); }else{ ans+=max(i.second,cnt[M-i.first]); } } cout<<ans<<'\n'; }