結果
問題 |
No.1972 Modulo Set
|
ユーザー |
|
提出日時 | 2022-06-18 11:37:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 1,009 bytes |
コンパイル時間 | 1,883 ms |
コンパイル使用メモリ | 175,896 KB |
実行使用メモリ | 9,600 KB |
最終ジャッジ日時 | 2024-10-09 23:05:10 |
合計ジャッジ時間 | 5,108 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include<bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; using ll = long long; using P = pair<int,int>; using Pll = pair<ll,ll>; using Graph = vector<vector<int>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i,n) for(ll i = 1; i <= (n); ++i) #define drep(i,n) for(ll i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (ll i = s; i < (t); ++i) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() void solve(){ ll n,m; cin >> n >> m; map<ll,ll> mp; rep(i,n){ ll a; cin >> a; mp[a%m]++; } ll ans = 0; for(auto x : mp){ if(2*x.first%m == 0){ ans++; continue; } if(!mp.count((m-x.first)%m)){ ans += x.second; continue; } ll y = (m-x.first)%m; if(x.first > y) continue; ans += max(mp[x.first],mp[y]); } cout << ans << endl; } int main(void){ solve(); return 0; }