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 fcacd45 commit 9e63560Copy full SHA for 9e63560
atcoder/abc053/D/main.cpp
@@ -0,0 +1,43 @@
1
+#include <bits/stdc++.h>
2
+
3
+using namespace std;
4
+using ll = long long;
5
6
+int N;
7
+vector<int> A;
8
9
+int solve() {
10
+ unordered_map<int,int> mp;
11
+ for (auto a : A) {
12
+ ++mp[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;
29
+}
30
31
+int main() {
32
+ ios_base::sync_with_stdio(false);
33
+ cin.tie(0); cout.tie(0);
34
35
+ cin >> N;
36
+ A.assign(N, 0);
37
+ for (int i = 0; i < N; ++i) {
38
+ cin >> A[i];
39
40
+ cout << solve() << endl;
41
42
+ return 0;
43
0 commit comments