Result: Accepted
Time: 6ms
Memory: 1096kB
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
int i,j,k,t,a1,a2,a3,b1[1002],b2[1002],b3[1002],n,max1=-1,max2=-1,max3=-1,p1=0,p2=0,p3=0;
char m[102][102];
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d %s",&n,&m[i]);
b1[i]=0;
b2[i]=0;
b3[i]=0;
for(k=0;k<n;k++){
scanf("%d-%d-%d",&a1,&a2,&a3);
if(a1/10==a1%10&&a2/10==a2%10&&a3/10==a3%10&&a1==a2&&a2==a3)
b1[i]++;
else if(a1/10>a1%10&&a2/10>a2%10&&a3/10>a3%10&&a1%10>a2/10&&a2%10>a3/10)
b2[i]++;
else
b3[i]++;
}
}
for(i=0;i<t;i++){
if(b1[i]>max1)
max1=b1[i];
}
for(i=0;i<t;i++){
if(b2[i]>max2)
max2=b2[i];
}
for(i=0;i<t;i++){
if(b3[i]>max3)
max3=b3[i];
}
for(i=0;i<t;i++){
if(b1[i]==max1)
p1++;
}
for(i=0;i<t;i++){
if(b2[i]==max2)
p2++;
}
for(i=0;i<t;i++){
if(b3[i]==max3)
p3++;
}
printf("If you want to have a keyboard, you should call: ");
k=1;
for(i=0;i<t;i++){
if(k!=p1){
if(b1[i]==max1){
printf("%s, ",m[i]);
k++;
}
}
else if(k==p1){
if(b1[i]==max1){
printf("%s.\n",m[i]);
k++;
}
}
}
printf("If you want to order a Watchdog2, you should call: ");
k=1;
for(i=0;i<t;i++){
if(k!=p2){
if(b2[i]==max2){
printf("%s, ",m[i]);
k++;
}
}
else if(k==p2){
if(b2[i]==max2){
printf("%s.\n",m[i]);
k++;
}
}
}
printf("If you want to have a cup of coffee with a girl, you should call: ");
k=1;
for(i=0;i<t;i++){
if(k!=p3){
if(b3[i]==max3){
printf("%s, ",m[i]);
k++;
}
}
else if(k==p3){
if(b3[i]==max3){
printf("%s.\n",m[i]);
k++;
}
}
}
return 0;
}