結果
問題 |
No.1972 Modulo Set
|
ユーザー |
|
提出日時 | 2022-11-18 16:07:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 1,662 bytes |
コンパイル時間 | 1,831 ms |
コンパイル使用メモリ | 179,464 KB |
実行使用メモリ | 21,120 KB |
最終ジャッジ日時 | 2024-09-19 22:01:10 |
合計ジャッジ時間 | 4,932 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
外部呼び出し有り |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; using namespace std; //using namespace atcoder; //using mint = modint1000000007; //using mint2 = modint998244353; typedef long long ll; #define rep1(i, m, n) for(int i = m; i < (int)(n); i++) #define rep2(i, m, n) for(int i = m; i <= (int)(n); i++) #define all(x) x.begin(), x.end() #define rall(x) xkkkk.rbegin(), x.rend() template<class T> inline bool chmax(T& a, T b) { if(a < b) {a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if(a > b) {a = b; return true; } return false; } const ll INF = 1LL << 60; //#define _GLIBCXX_DEBUG // 範囲外エラーを教えてくれる。使うときはincludeより上に置く。 // const char newl='\n'; int main() { ll n,m; cin >> n >> m; vector<ll> a(n); for (int i=0; i<n; i++) { cin >> a[i]; a[i]%=m; } map<ll,ll> data; for (int i=0; i<n; i++) data[a[i]]++; map<ll,ll> ans; set<ll> idx; for (auto p:data) { /* if (idx.count(p.first)) continue; if (!data.count(m-p.first)) { ans+=p.second; idx.insert(p.first); continue; } if (p.second>=data[m-p.first]) { ans+=p.second; idx.insert(p.first); idx.insert(m-p.first); } */ ll t=max(p.first,m-p.first); if (ans.count(t)) continue; if (m==2*p.first) { ans[t]=1; continue; } if (p.first==0) { ans[t]=1; continue; } ans[t]=max(p.second,data[m-p.first]); int c=0; } ll s=0; for (auto p:ans) s+=p.second; cout << s << endl; system("pause"); }