-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcandies.cpp
More file actions
40 lines (39 loc) · 886 Bytes
/
candies.cpp
File metadata and controls
40 lines (39 loc) · 886 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
#include <iostream>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n, count = 0;
cin >> n;
int a[2 * n];
for (int i = 0; i < 2 * n; i++)
{
cin >> a[i];
}
for (int i = 0; i < 2 * n; i++)
{
for (int j = i + 1; j < 2 * n; j++)
{
if (a[i] > a[j])
{
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
for (int i = 0; i < 2 * n - 2; i++)
{
if (a[i] == a[i + 1] && a[i + 1] == a[i + 2])
count += 2;
}
if (count > 2 || count == 2)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}