-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF.cpp
More file actions
54 lines (49 loc) · 1.04 KB
/
Copy pathF.cpp
File metadata and controls
54 lines (49 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repx(i, a, n) for(int i = a; i < n; i++)
#define eb emplace_back
#define debugv(v) cerr<<#v<<':'; for(auto e: v) cerr<<' '<<e;cerr<<endl
int main(){
int n,m;
cin>>n>>m;
vi lol(m,0);
rep(i,n){
int u;
cin>>u;
u--;
lol[u]++;
}
int k = 0;
int repetidos = 0;
rep(i,m){
if(lol[i] > 0){
k++;
if(lol[i] > 1){
repetidos++;
}
}
}
if(repetidos > 1 and k < m)
cout<< m<<endl;
else if(repetidos == 0 and k < m){
if(k==2)
cout<<m-2<<endl;
else if(k==3 and m ==4)
cout<< 3<<endl;
else
cout<< m <<endl;
}
else if(repetidos == 1){
if(k >= 3)
cout<<m<<endl;
else if(k==2)
cout <<m-1<<endl;
else
cout<< 1<<endl;
}
else
cout<< 0 <<endl;
}