Result: Accepted
Time: 1ms
Memory: 1096kB
#include "stdio.h"
#include "string.h"
int key[101],wat[101],cup[101],x1[101],x2[101],x3[101];
int main(){
int n,m,i,j,k,bl1,bl2,sum1,sum2,sum3,b;
int max1,max2,max3;
char ch1[101][21],ch2[10];
scanf("%d",&n);
for(i=0;i<n;++i){
scanf("%d %s",&m,ch1[i]);
getchar();
for(j=0;j<m;++j){
gets(ch2);
b=0;
bl1=1;
for(k=0;k<8;++k){
if(ch2[k]=='-') continue;
else {
if(ch2[k]!=ch2[b]){bl1=0; break;}
else b=k;
}
}
if(bl1==1) ++key[i];
b=0;
bl2=1;
for(k=0;k<8;++k){
if(ch2[k]=='-') continue;
else {
if(k!=0){
if(ch2[k]>=ch2[b]){bl2=0; break;}
else b=k;
}
else continue;
}
}
if(bl2==1) ++wat[i];
if(bl1==0&&bl2==0) ++cup[i];
}
}
sum1=0;sum2=0;sum3=0;
for(i=0;i<n;++i){
if(i==0) {max1=key[i]; max2=wat[i]; max3=cup[i]; continue;}
if(key[i]>max1) {max1=key[i]; x1[0]=i;
for(j=1;j<n;++j)
x1[j]=0;
sum1=0;
}
else if(key[i]==max1) {++sum1; x1[sum1]=i;}
if(wat[i]>max2) {max2=wat[i]; x2[0]=i;
for(j=1;j<n;++j)
x2[j]=0;
sum2=0;
}
else if(wat[i]==max2) {++sum2; x2[sum2]=i;}
if(cup[i]>max3) {max3=cup[i]; x3[0]=i;
for(j=1;j<n;++j)
x3[j]=0;
sum3=0;
}
else if(cup[i]==max3) { ++sum3; x3[sum3]=i;}
}
printf("If you want to have a keyboard, you should call: ");
for(i=0;i<=sum1;++i){
printf("%s",ch1[x1[i]]);
if(i!=sum1)
printf(", ");
}
printf(".");
printf("\n");
printf("If you want to order a Watchdog2, you should call: ");
for(i=0;i<=sum2;++i){
printf("%s",ch1[x2[i]]);
if(i!=sum2)
printf(", ");
}
printf(".");
printf("\n");
printf("If you want to have a cup of coffee with a girl, you should call: ");
for(i=0;i<=sum3;++i){
printf("%s",ch1[x3[i]]);
if(i!=sum3)
printf(", ");
}
printf(".");
printf("\n");
return 0;
}