結果

問題 No.1972 Modulo Set
ユーザー rurunrurun
提出日時 2022-11-18 15:23:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 1,791 ms
コンパイル使用メモリ 176,520 KB
実行使用メモリ 10,168 KB
最終ジャッジ日時 2023-10-20 01:42:19
合計ジャッジ時間 6,852 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 65 ms
6,472 KB
testcase_17 AC 22 ms
4,500 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 51 ms
6,208 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 43 ms
5,944 KB
testcase_23 AC 87 ms
9,112 KB
testcase_24 AC 31 ms
5,680 KB
testcase_25 AC 49 ms
6,736 KB
testcase_26 WA -
testcase_27 AC 93 ms
9,376 KB
testcase_28 AC 31 ms
5,680 KB
testcase_29 AC 48 ms
6,736 KB
testcase_30 AC 67 ms
8,056 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 62 ms
7,528 KB
testcase_33 AC 108 ms
10,168 KB
testcase_34 AC 107 ms
10,168 KB
testcase_35 AC 105 ms
10,168 KB
testcase_36 AC 109 ms
9,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
  lint n, m;
  cin >> n >> m;
  vector<lint> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  map<lint, lint> ma;
  for (int i = 0; i < n; i++) ma[vec[i]%m]++;
  lint ans = 0;
  for (auto pa : ma) {
    lint x = pa.first;
    lint y = pa.second;
    if (m-x == x) ans++;
    else if (ma.count(m-x)) {
      if (m-x < x) continue;
      else ans += max(y, ma.at(m-x));
    }
    else ans += y;
    /*
    if (m-x == x) ans++;
    else if (m-x < x) break;
    else {
      if (ma.count(m-x)) {
        ans += max(ma.at(m-x), y);
      }
    }
    //*/
  }
  cout << ans << endl;
}
0