結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2024-04-18 02:43:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 740 ms |
| コンパイル使用メモリ | 78,484 KB |
| 最終ジャッジ日時 | 2025-02-21 02:56:59 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <iostream>
#include <map>
#include <utility>
#define rep(i,n) for(int i=0; i<int(n); i++)
using i64 = long long;
using namespace std;
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
int N; cin >> N;
i64 M; cin >> M;
map<i64, pair<int,int>> A;
int t = 0;
int s = 0;
rep(i,N){
i64 a; cin >> a;
a %= M;
if(a == 0) t = 1;
else if(a*2 == M) s = 1;
else{
if(M-a < a) A[a].first++; else A[M-a].second++;
}
}
for(auto a : A) t += max(a.second.first, a.second.second);
cout << (t+s) << endl;
return 0;
}
Nachia