Submission #60988748


Source Code Expand

#include<bits/stdc++.h>
#define ll long long
#define fi(l) freopen(l".in","r",stdin)
#define fo(l) freopen(l".out","w",stdout)
//#pragma G++ optimize(2)
using namespace std;
inline ll read()
{
	ll v=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
inline void out(ll x)
{
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	if(x<10)putchar(x+'0');
	else 
	{
		out(x/10);
		putchar(x%10+'0');
	}
}
ll h[3020],hhh[3020];
int main()
{
	//fi("");
	//fo("");
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	//cout.tie(0);
	ll n=read();
	for(ll i=1;i<=n;i++)
	{
		h[i]=read();
		hhh[i]=h[i];
	}
	sort(hhh+1,hhh+n+1);
	bool f=true;
	for(ll i=1;i<n;i++)
	{
		if(hhh[i]==hhh[i+1])
		{
			f=false;
			break;
		}
	}
	if(f||n==1)
	{
		out(1);
		return 0;
	}
	ll ans=0;
	for(ll k=1;k<n;k++)
	{
		for(ll i=1;i<=n-k;i++)
		{
			ll cnt=1;
			for(ll j=i+k;j<=n;j+=k)
			{
				if(h[j]!=h[j-k])break;
				else cnt++;
			}
			ans=max(ans,cnt);
		}
	}
	out(ans);
	return 0;
}

Submission Info

Submission Time
Task C - Illuminate Buildings
User HG27895
Language C++ 17 (gcc 12.2)
Score 350
Code Size 1131 Byte
Status AC
Exec Time 22 ms
Memory 3744 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 6 ms 3552 KiB
random_02.txt AC 3 ms 3660 KiB
random_03.txt AC 5 ms 3704 KiB
random_04.txt AC 1 ms 3588 KiB
random_05.txt AC 6 ms 3492 KiB
random_06.txt AC 3 ms 3476 KiB
random_07.txt AC 5 ms 3616 KiB
random_08.txt AC 1 ms 3708 KiB
random_09.txt AC 6 ms 3744 KiB
random_10.txt AC 5 ms 3544 KiB
random_11.txt AC 5 ms 3704 KiB
random_12.txt AC 1 ms 3544 KiB
random_13.txt AC 7 ms 3580 KiB
random_14.txt AC 4 ms 3696 KiB
random_15.txt AC 5 ms 3604 KiB
random_16.txt AC 3 ms 3500 KiB
random_17.txt AC 6 ms 3544 KiB
random_18.txt AC 5 ms 3608 KiB
random_19.txt AC 6 ms 3612 KiB
random_20.txt AC 4 ms 3696 KiB
random_21.txt AC 22 ms 3488 KiB
random_22.txt AC 20 ms 3600 KiB
random_23.txt AC 20 ms 3620 KiB
random_24.txt AC 1 ms 3580 KiB
random_25.txt AC 1 ms 3504 KiB
sample_01.txt AC 1 ms 3540 KiB
sample_02.txt AC 1 ms 3632 KiB
sample_03.txt AC 1 ms 3500 KiB