Skip to content

Commit c3d2bc0

Browse files
committed
atcoder/abc053D (feedback from editorial)
1 parent 9e63560 commit c3d2bc0

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

atcoder/abc053/D/main.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,13 @@ int N;
77
vector<int> A;
88

99
int solve() {
10-
unordered_map<int,int> mp;
10+
unordered_set<int> s;
1111
for (auto a : A) {
12-
++mp[a];
12+
s.insert(a);
1313
}
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;
14+
int K = s.size();
15+
if (K % 2 == 0) return K - 1;
16+
else return K;
2917
}
3018

3119
int main() {

0 commit comments

Comments
 (0)