結果
問題 | No.1972 Modulo Set |
ユーザー |
![]() |
提出日時 | 2022-06-12 23:07:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 804 bytes |
コンパイル時間 | 616 ms |
コンパイル使用メモリ | 57,468 KB |
実行使用メモリ | 9,216 KB |
最終ジャッジ日時 | 2024-10-05 01:45:39 |
合計ジャッジ時間 | 2,833 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
/* -*- coding: utf-8 -*- * * 1972.cc: No.1972 Modulo Set - yukicoder */ #include<cstdio> #include<map> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ typedef long long ll; typedef map<ll,int> mli; /* global variables */ ll as[MAX_N]; /* subroutines */ /* main */ int main() { int n; ll m; scanf("%d%lld", &n, &m); mli acs; for (int i = 0; i < n; i++) { ll ai; scanf("%lld", &ai); acs[ai % m]++; } int sum = 0; for (auto ac: acs) { ll a = ac.first, b = m - a; int c = ac.second; if (a == 0 || a * 2 == m) sum++; else { mli::iterator mit = acs.find(b); if (mit == acs.end()) sum += c; else if (a < b) sum += max(c, mit->second); } } printf("%d\n", sum); return 0; }