mirror of
https://github.com/tiennm99/codeforces.git
synced 2026-10-14 10:18:15 +00:00
[Init] Solved solutions
This commit is contained in:
1 parent
51f667ac81
commit
20542601dd
131 files changed
+4148
No files matched your search
+51
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace _602B
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int n = int.Parse(Console.ReadLine());
|
||||
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
|
||||
int[] b = a.ToArray();
|
||||
int[] c = a.ToArray();
|
||||
int c1 = 1, c2 = 1, max = 1;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (a[i] % 2 == 1)
|
||||
{
|
||||
b[i]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
c[i]++;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < n; i++)
|
||||
{
|
||||
if (b[i] == b[i - 1])
|
||||
{
|
||||
c1++;
|
||||
}
|
||||
else
|
||||
{
|
||||
max = Math.Max(max, c1);
|
||||
c1 = 1;
|
||||
}
|
||||
if (c[i] == c[i - 1])
|
||||
{
|
||||
c2++;
|
||||
}
|
||||
else
|
||||
{
|
||||
max = Math.Max(max, c2);
|
||||
c2 = 1;
|
||||
}
|
||||
}
|
||||
max = Math.Max(Math.Max(c1, c2), max);
|
||||
Console.WriteLine(max);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user