-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Sushi_for_Two.cpp
More file actions
67 lines (62 loc) · 1.23 KB
/
A_Sushi_for_Two.cpp
File metadata and controls
67 lines (62 loc) · 1.23 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
/*____________________________________________________
|Author: Ki6ui-Par1na
|Date: 2024/05/16
|Time: 14:06:54
|Problem: A_Sushi_for_Two
|____________________________________________________*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define print(n) cout << (n) << endl;
#define tc \
ll t; \
cin >> t; \
while (t--)
void solve()
{
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i];
}
int cn1 = 0, cn2 = 0, mx1 = -1, mx2 = -1, countOne = 0, countTwo = 0;
for (int i = 0; i < n; i++)
{
if (v[i] == 1)
{
countOne++;
cn1++;
mx1 = max(mx1, cn1);
mx2 = max(mx2, cn2);
cn2 = 0;
}
else
{
countTwo++;
cn2++;
mx1 = max(mx1, cn1);
mx2 = max(mx2, cn2);
cn1 = 0;
}
}
if (countOne > countTwo)
{
cout << 2 * mx2 << endl;
}
else
{
cout << 2 * mx1 << endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
solve();
return 0;
}