Result: Accepted
Time: 1ms
Memory: 1332kB
#include<stdio.h>
#include<stdlib.h>
struct peo
{
char name[20];
int key,watch,cof;
int phone[100][9];
};
int main(void)
{
struct peo people[100];
int T,m,i,j,temp;
char ch;
scanf("%d",&T);
for(i=1;i<=T;++i)
{
scanf("%d %s",&m,people[i].name);
people[i].key=0;
people[i].watch=0;
people[i].cof=0;
for(j=1;j<=m;++j)
{
scanf("%d%c%d%c%d",&people[i].phone[j][7],&ch,&people[i].phone[j][8],&ch,&people[i].phone[j][9],&ch);
people[i].phone[j][1]=(people[i].phone[j][7]/10)%10;
people[i].phone[j][2]=people[i].phone[j][7]%10;
people[i].phone[j][3]=(people[i].phone[j][8]/10)%10;
people[i].phone[j][4]=people[i].phone[j][8]%10;
people[i].phone[j][5]=(people[i].phone[j][9]/10)%10;
people[i].phone[j][6]=people[i].phone[j][9]%10;
if(people[i].phone[j][1]==people[i].phone[j][2]&&people[i].phone[j][2]==people[i].phone[j][3]&&people[i].phone[j][3]==people[i].phone[j][4]&&people[i].phone[j][4]==people[i].phone[j][5]&&people[i].phone[j][5]==people[i].phone[j][6])
people[i].key+=1;
else if(people[i].phone[j][1]>people[i].phone[j][2]&&people[i].phone[j][2]>people[i].phone[j][3]&&people[i].phone[j][3]>people[i].phone[j][4]&&people[i].phone[j][4]>people[i].phone[j][5]&&people[i].phone[j][5]>people[i].phone[j][6])
people[i].watch+=1;
else
people[i].cof+=1;
}
}
int a=-1,b=-1,c=-1,d,e,f;
for(int g=1;g<=T;++g)
{
if(people[g].key>a)
{
a=people[g].key;
d=g;
}
if(people[g].watch>b)
{
b=people[g].watch;
e=g;
}
if(people[g].cof>c)
{
c=people[g].cof;
f=g;
}
}
printf("If you want to have a keyboard, you should call:");
printf(" %s",people[d].name);
for(int h=1;h<=T;h++)
{
if(h==d)
continue;
if(people[h].key==a)
printf(", %s",people[h].name);
}
printf(".\n");
printf("If you want to order a Watchdog2, you should call:");
printf(" %s",people[e].name);
for(int h=1;h<=T;h++)
{
if(h==e)
continue;
if(people[h].watch==b)
printf(", %s",people[h].name);
}
printf(".\n");
printf("If you want to have a cup of coffee with a girl, you should call:");
printf(" %s",people[f].name);
for(int h=1;h<=T;h++)
{
if(h==f)
continue;
if(people[h].cof==c)
printf(", %s",people[h].name);
}
printf(".\n");
}