結果

問題 No.1972 Modulo Set
ユーザー Gorin2006Gorin2006
提出日時 2022-11-18 16:07:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 1,662 bytes
コンパイル時間 1,791 ms
コンパイル使用メモリ 180,036 KB
実行使用メモリ 21,344 KB
最終ジャッジ日時 2023-10-20 02:13:09
合計ジャッジ時間 5,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 15 ms
4,348 KB
testcase_04 AC 22 ms
4,348 KB
testcase_05 AC 24 ms
4,348 KB
testcase_06 AC 38 ms
4,624 KB
testcase_07 AC 58 ms
4,964 KB
testcase_08 AC 26 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 22 ms
4,348 KB
testcase_11 AC 56 ms
5,016 KB
testcase_12 AC 11 ms
4,348 KB
testcase_13 AC 8 ms
4,492 KB
testcase_14 AC 8 ms
4,540 KB
testcase_15 AC 67 ms
7,408 KB
testcase_16 AC 78 ms
9,240 KB
testcase_17 AC 26 ms
5,392 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 67 ms
9,360 KB
testcase_20 AC 81 ms
10,200 KB
testcase_21 AC 32 ms
5,604 KB
testcase_22 AC 58 ms
9,100 KB
testcase_23 AC 148 ms
18,396 KB
testcase_24 AC 52 ms
9,724 KB
testcase_25 AC 83 ms
12,860 KB
testcase_26 AC 88 ms
8,360 KB
testcase_27 AC 148 ms
19,328 KB
testcase_28 AC 58 ms
9,984 KB
testcase_29 AC 92 ms
13,176 KB
testcase_30 AC 126 ms
16,700 KB
testcase_31 AC 8 ms
4,420 KB
testcase_32 AC 114 ms
15,496 KB
testcase_33 AC 166 ms
21,344 KB
testcase_34 AC 167 ms
21,332 KB
testcase_35 AC 169 ms
21,336 KB
testcase_36 AC 170 ms
21,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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");
}
0