-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathARRGAME.cpp
More file actions
76 lines (63 loc) · 1.25 KB
/
ARRGAME.cpp
File metadata and controls
76 lines (63 loc) · 1.25 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//https://www.codechef.com/problems/ARRGAME?tab=statement
#include <iostream>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <deque>
#include <list>
#include <forward_list>
#include <utility>
#include <algorithm>
#include <vector>
#include <array>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef unsigned long int ul;
typedef unsigned short us;
typedef unsigned char uc;
typedef long long int ll;
void solve();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
solve();
return 0;
}
void solve()
{
ll n;
cin >> n;
int count = 0;
int max1 = 0;
int max2 = 0;
vector<int> arr(n);
for (int i = 0; i < n; i++)
{
cin >> arr[i];
if (arr[i] != 1)
count++;
else
{
if (count >= max1)
{
max2 = max1;
max1 = count;
}
else if (count > max2)
{
max2 = count;
}
count = 0;
}
}
if (max1 != 0 && max1 % 2 == 1 && max2 < (max1 + 1) / 2)
cout << "Yes\n";
else
cout << "No\n";
}