Cod sursa(job #9574)

Utilizator sweet_aliceLupsan Alice sweet_alice Data 27 ianuarie 2007 16:14:35
Problema Pascal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <stdio.h>

int a,l,i,max,n,max2;

int main()
{
	freopen("maxsecv.in","r",stdin);
	freopen("maxsecv.out","w",stdout);

	scanf("%d",&n);

	l=0;
	max=-32000;
	max2=-32000;

	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);

		l=0;

		if(a==1)
		{
			++l;
			while(scanf("%d",&a)==1 && a==1)
			{
				++i;
				++l;
			}
		}

		if(l>=max)
		{

			max2=max;
			max=l;
		}

	}

	printf("%d",max+max2);

	return 0;
}