Start: Dec, 04, 2016 12:00:00
杭州师范大学第十届程序设计竞赛—正式
End: Dec, 04, 2016 17:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 1ms
Memory: 1096kB
In contest: 1075

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int comp(const void *p, const void *q) {
	return (*(char *)p - *(char *)q);
}

typedef struct student {
	int m;
	char name[20];
	char number[8];
} student;

int main() {
	student stu[100];
	int count[100][3] = {0};
	int T;
	int i, j, k; 
	scanf("%d", &T);
	for( i = 0; i < T; i++) {
		scanf("%d", &stu[i].m);
		scanf("%s", &stu[i].name);
		for (j = 0; j < stu[i].m; j++) {
			scanf("%s", &stu[i].number);
			if (stu[i].number[0] == stu[i].number[1] &&
				stu[i].number[1] == stu[i].number[3] &&
				stu[i].number[3] == stu[i].number[4] &&
				stu[i].number[4] == stu[i].number[6] &&
				stu[i].number[6] == stu[i].number[7])
				count[i][0]++;
			else if (stu[i].number[0] > stu[i].number[1] &&
					 stu[i].number[1] > stu[i].number[3] &&
					 stu[i].number[3] > stu[i].number[4] &&
					 stu[i].number[4] > stu[i].number[6] &&
					 stu[i].number[6] > stu[i].number[7])
					 count[i][1]++;
			else
				count[i][2]++;
		}
	}
	int max = -1;
	int flag;
		for (int k = 0; k < T; k++) {
			if(count[k][0] > max)
				max = count[k][0];
		}
		printf("If you want to have a keyboard, you should call: ");
		flag = 1;
		for (k = 0; k < T; k++) {
			if(count[k][0] == max) {
				if (flag == 1) {
					printf("%s", stu[k].name);
					flag = 0;
				}
				else 
					printf(", %s", stu[k].name);
			}
		}
		printf(".\n");
		
		max = -1;
		for (k = 0; k < T; k++) {
			if(count[k][1] > max)
				max = count[k][1];
		}
		printf("If you want to order a Watchdog2, you should call: ");
		flag = 1;
		for (k = 0; k < T; k++) {
			if(count[k][1] == max) {
				if (flag == 1) {
					printf("%s", stu[k].name);
					flag = 0;
				}
				else 
					printf(", %s", stu[k].name);
			}
		}
		printf(".\n");
		
		max = -1;
		for (int k = 0; k < T; k++) {
			if(count[k][2] > max)
				max = count[k][2];
		}
		printf("If you want to have a cup of coffee with a girl, you should call: ");
		flag = 1;
		for (int k = 0; k < T; k++) {
			if(count[k][2] == max) {
				if (flag == 1) {
					printf("%s", stu[k].name);
					flag = 0;
				}
				else 
					printf(", %s", stu[k].name);
			}
		}
		printf(".\n");
	return 0;
}