Pagini recente » Cod sursa (job #1696364) | Cod sursa (job #2251914) | Cod sursa (job #2600100) | Cod sursa (job #976748) | Cod sursa (job #1325812)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
ifstream f("cutii.in");
ofstream g("cutii.out")
int i,n,t,j;
struct cutie
{
int a,b,c,s;
};
struct teste
{
cutie c[3501];
};
teste p[101];
void ordonare(cutie c[])
{
cutie sch;
int flag=0,h;
while(flag==0)
{
flag=1;
for(h=1;h<n;h++)
{
if(c[h].s<c[h+1].s)
{
sch=c[h];
c[h]=c[h+1];
c[h+1]=sch;
flag=0;
}
}
}
}
int test(cutie c[])
{
int s=1,k;
ordonare(c);
int vmax=1;
for(k=2;k<=n;k++)
{
if(c[k].s<=c[vmax].s-3)
{
if((c[k].a<c[vmax].a)&&(c[k].a<c[vmax].a)&&(c[k].a<c[vmax].a))
{
s++;
vmax=k;
}
}
}
return s;
}
int main()
{
f>>n>>t;
for(i=1;i<=t;i++)
{
for(j=1;j<=n;j++)
{
f>>p[i].c[j].a>>p[i].c[j].b>>p[i].c[j].c;
p[i].c[j].s=p[i].c[j].a+p[i].c[j].b+p[i].c[j].c;
}
}
for(i=1;i<=t;i++)g<<test(p[i].c)<<endl;
return 0;
}