contest6:A dilemma of HR

Problem A: A dilemma of HR

Time Limit: 1 Sec   Memory Limit: 15 MB
Submit: 260   Solved: 65
[ Submit][ Status][ Web Board]

Description

The manager of Human Resource(HR) is now facing a dilemma. He/She will face several candidates to several posts. Fortunately, the manager has just figured out an evaluation of  the candidates: each candidate will be evaluated in the order of their general score, bonus, as well as penalty.

Now you are going to implement a program to help the manager decide which candidate to be hired. The rule is to pick the one with highest score, when there is a tie among the scores, the man with more bonus would be the lucky one. However, there might yet be a tie in the previous comparison, thus you need to hire the one with least penalty in this situation.

There would be no duplication in each candidate group.

Input

Each candidate would be represented by a line with his/her interview number, score, bonus and penalty, sperated by space. When the presentation of all candidates for this post is end, a string "end of group" would be presented. Finally, "end" indicates all posts are viewed by the program and you may exit.

An example is as follow:

1 100 30 10

2 100 50 20

end of group

1 68 30 20

2 64 40 14

3 68 30 18

end of group

end

In the first group, interviewee 2  should be hired, while in the next group interviewee 3 is the lucky one.

Output

Please output the number of interviewee who would be hired.

Sample Input

1 100 30 10
2 100 50 20
end of group
1 68 30 20
2 64 40 14
3 68 30 18
end of group
end

Sample Output

2
3

HINT

#include<stdio.h>
int ifnum(char c)
{
	return (c >= '0' && c <= '9');
}



int best(int n,int* a, int* b, int* c)
{
	int i,j,l;
	int k = a[0];
	int p[10] = { 0 }, q[10] = { 0 } , r[10] = { 0 };
	for (i = 0; i < n; i++)
	{
		if (k < a[i])
			k = a[i];
	}
	for (i = 0,j = 0; i < n; i++)
	{
		if (k == a[i])
		{
			p[j] = i;
			j++;
		}
	}

	l = j ;
	if (l == 1)
		return p[0]+1;
	else
	{
		k = b[p[0]];
		for (i = 0; i < l; i++)
		{
			if (k < b[p[i]])
				k = b[p[i]];
		}
		for (i = 0, j = 0; i < l; i++)
		{
			if (b[p[i]] == k)
			{
				q[j] = p[i];
				j++;
			}
		}

		l = j;

		if (l==1)
			return q[0]+1;
		else
		{
			k = c[q[0]];
			for (i = 0; i < l; i++)
			{
				if (k > c[q[i]])
					k = c[q[i]];
			}
			for (i = 0, j = 0; i < l; i++)
			{
				if (k == c[q[i]])
				{
					r[j] = q[i];
				}
			}

				return r[0]+1;


		}
	}

}





int group()
{
	int i,num,good;
	int score[100] = { 0 },  bonus[100] = { 0 }, penalty[100] = { 0 };
	char str[30];
	getchar();
	scanf("%d %d %d", &score[0], &bonus[0], &penalty[0]);
	getchar();
	for (i = 1; ifnum(getchar()); i++)//scanf从getchar取走number之后的分数里扫描
	{   getchar();
		scanf("%d %d %d", &score[i], &bonus[i], &penalty[i]);

		getchar();
	}
	gets(str);//清空缓存
	num=i;
	good= best(num,score, bonus, penalty);
		return good;


}


int main()
{
	int i;
	while (ifnum(getchar()))
	{
		i = group();
		printf("%d\n", i);
	}
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值