-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeta.cpp
More file actions
51 lines (42 loc) · 929 Bytes
/
beta.cpp
File metadata and controls
51 lines (42 loc) · 929 Bytes
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
// NOTE: it is recommended to use this even if you don't understand the following code.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
// input data
long long N;
vector<long long> V;
int main() {
// uncomment the following lines if you want to read/write from files
ifstream cin("input.txt");
ofstream cout("output.txt");
cin >> N;
V.resize(N);
for (long long i=0; i<N; i++)
cin >> V[i];
// insert your code here
bool ans = false;
bool doppio = false;
long long num;
sort(V.begin(), V.end());
for (long long i=1; i<N; i++) {
if (V[i] == V[i-1]) {
if (!doppio) {
doppio = true;
num = V[i];
} else {
if (V[i] != num) {
ans = true;
break;
}
}
}
}
if (ans) {
cout << "YES" << endl; // print the result
} else {
cout << "NO" << endl;
}
return 0;
}