-
Notifications
You must be signed in to change notification settings - Fork 86
/
1138A. Sushi For Two.cpp
66 lines (49 loc) · 1.12 KB
/
1138A. Sushi For Two.cpp
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
/***from dust i have come, dust i will be***/
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define dbg printf("in\n")
#define nl printf("\n")
#define N 510
#define inf 1e6
#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)
#define pf(n) printf("%d",n)
#define pff(n,m) printf("%d %d",n,m)
#define pffl(n,m) printf("%I64d %I64d",n,m)
#define pfl(n) printf("%I64d",n)
#define pfs(s) printf("%s",s)
#define pb push_back
#define pp pair<int, int>
using namespace std;
int main()
{
freopen("in.txt", "r", stdin);
int i, j, k;
int n, m;
sf(n);
int a[n];
for(i = 0; i <n; i++)
sf(a[i]);
int cnt = 1;
vector<int> vec;
for(i = 1;i < n;i++)
{
if(a[i] != a[i - 1])
vec.pb(cnt), cnt = 1;
else
cnt++;
}
vec.pb(cnt);
int ans = 0;
if(vec.size() > 1)
{
n = vec.size();
for(i = 0; i < n - 1; i++)
ans = max(ans, min(vec[i], vec[i + 1]));
}
pf(ans * 2);
return 0;
}