Result: Accepted
Time: 2ms
Memory: 1096kB
#include <stdio.h>
int main(void)
{
int T , m ,a ,c;
a=0;
scanf("%d",&T);
int b[6];
char name[100][20];
int x[100];
int y[100];
int z[100];
while(T--)
{
x[a]=0;
y[a]=0;
z[a]=0;
scanf("%d%s",&m,name[a]);
while(m--)
{
scanf("%d-%d-%d",&b[0],&b[2],&b[4]);
b[1]=b[0]%10;
b[3]=b[2]%10;
b[5]=b[4]%10;
b[4]=b[4]/10;
b[2]=b[2]/10;
b[0]=b[0]/10;
if(b[1]==b[2]&&b[1]==b[3]&&b[1]==b[4]&&b[1]==b[5]&&b[1]==b[0])
++x[a];
else if(b[0]>b[1]&&b[1]>b[2]&&b[2]>b[3]&&b[3]>b[4]&&b[4]>b[5])
++y[a];
else
++z[a];
}
a++;
}
int max,d,f;
int e[100];
for(d=1,max=x[0],e[0]=0,f=0;d<a;++d)
{
if(x[d]>max)
{
f=0;
e[f]=d;
max=x[d];
}
else if(x[d]==max)
{
f++;
e[f]=d;
}
}
printf("If you want to have a keyboard, you should call: ");
for(d=0;d<=f;++d)
{
if(d==f)
printf("%s",name[e[d]]);
else
printf("%s, ",name[e[d]]);
}
printf(".\n");
for(d=1,max=y[0],e[0]=0,f=0;d<a;++d)
{
if(y[d]>max)
{
f=0;
e[f]=d;
max=y[d];
}
else if(y[d]==max)
{
f++;
e[f]=d;
}
}
printf("If you want to order a Watchdog2, you should call: ");
for(d=0;f>=d;++d)
{
if(d==f)
printf("%s",name[e[d]]);
else
printf("%s, ",name[e[d]]);
}
printf(".\n");
for(d=1,max=z[0],e[0]=0,f=0;d<a;++d)
{
if(z[d]>max)
{
f=0;
e[f]=d;
max=z[d];
}
else if(z[d]==max)
{
f++;
e[f]=d;
}
}
printf("If you want to have a cup of coffee with a girl, you should call: ");
for(d=0;f>=d;++d)
{
if(d==f)
printf("%s",name[e[d]]);
else
printf("%s, ",name[e[d]]);
}
printf(".");
return 0;
}