We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e63560 commit c3d2bc0Copy full SHA for c3d2bc0
atcoder/abc053/D/main.cpp
@@ -7,25 +7,13 @@ int N;
7
vector<int> A;
8
9
int solve() {
10
- unordered_map<int,int> mp;
+ unordered_set<int> s;
11
for (auto a : A) {
12
- ++mp[a];
+ s.insert(a);
13
}
14
-
15
- int ans = N;
16
- int m = 0;
17
- for (auto e : mp) {
18
- auto c = e.second;
19
- int r = (c - 1) % 2 + 1;
20
- ans -= (c - r);
21
- if (r == 2) ++m;
22
- }
23
- if (m % 2 == 0) {
24
- ans -= m;
25
- } else {
26
- ans -= m + 1;
27
28
- return ans;
+ int K = s.size();
+ if (K % 2 == 0) return K - 1;
+ else return K;
29
30
31
int main() {
0 commit comments