結果

問題 No.1972 Modulo Set
ユーザー tonyu0tonyu0
提出日時 2022-06-10 23:33:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,214 bytes
コンパイル時間 1,085 ms
コンパイル使用メモリ 112,520 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2023-10-21 05:50:21
合計ジャッジ時間 5,543 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 14 ms
4,348 KB
testcase_04 AC 20 ms
4,348 KB
testcase_05 WA -
testcase_06 AC 38 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 59 ms
4,508 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 7 ms
4,348 KB
testcase_15 AC 83 ms
6,092 KB
testcase_16 AC 104 ms
7,148 KB
testcase_17 AC 25 ms
4,680 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 78 ms
7,168 KB
testcase_20 AC 107 ms
7,940 KB
testcase_21 AC 33 ms
4,784 KB
testcase_22 AC 71 ms
7,148 KB
testcase_23 AC 208 ms
13,220 KB
testcase_24 AC 54 ms
7,536 KB
testcase_25 AC 91 ms
9,536 KB
testcase_26 WA -
testcase_27 AC 195 ms
14,012 KB
testcase_28 AC 52 ms
7,708 KB
testcase_29 AC 90 ms
9,788 KB
testcase_30 AC 145 ms
12,164 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 134 ms
11,372 KB
testcase_33 AC 234 ms
15,332 KB
testcase_34 AC 235 ms
15,332 KB
testcase_35 AC 236 ms
15,332 KB
testcase_36 AC 232 ms
15,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)
#define all(a) a.begin(), a.end()
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i];
  return os << '\n';
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (T &x : a) { is >> x; }
  return is;
}
[[maybe_unused]] constexpr long long MOD = 998244353;
// constexpr long long MOD = 1000000007;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr long long INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  cin >> a;
  map<ll, ll> mp;
  for (ll b : a) mp[b % m]++;
  ll ans = 0;
  ll zero = 0;
  for (ll b : a) {
    ll c = b % m;
    if (c == 0) {
      zero = 1;
    } else {
      ans += max(mp[c], mp[m - c]);
    }
    mp[c] = mp[m - c] = 0;
  }
  cout << ans + zero;
}
0