結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-18 15:41:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,457 bytes |
| コンパイル時間 | 1,911 ms |
| コンパイル使用メモリ | 183,440 KB |
| 実行使用メモリ | 15,232 KB |
| 最終ジャッジ日時 | 2024-09-19 21:43:21 |
| 合計ジャッジ時間 | 5,670 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 13 |
ソースコード
#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> data2;
for (int i=0; i<n; i++) if (data.count(m-a[i])) data2[a[i]]+=data[m-a[i]];
ll ans=0;
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);
}
}
cout << ans << endl;
system("pause");
}