Cod sursa(job #733902)

Utilizator robertpoeRobert Poenaru robertpoe Data 13 aprilie 2012 10:20:33
Problema Cutii Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include<fstream>
using namespace std;
ifstream f("cutii.in");
ofstream g("cutii.out");
int n,t,i,j,a[3501],b[3501],l[3501],x,y,z,sc,k;
int main()
{
	f>>n>>t;
	for(i=1;i<=t;i++)
	{
		for(j=1;j<=n;j++)
		{
			f>>x>>y>>z;
			a[x]=y;
			b[x]=z;
		}
		l[1]=1;
		sc=1;
		for(j=2;j<=n;j++)
		{
			l[j]=1;
			for(k=j-1;k>=1;k--)
			{
				if(a[k]<a[j])
					if(b[k]<b[j])
						if((l[k]+1)>l[j])
						{
							l[j]=l[k]+1;
							if(l[j]>sc)sc=l[j];
						}
			}
		}
		g<<sc<<"\n";
	}
	return 0;
}