11727 - Cost Cutting
Time limit: 1.000 seconds
Company XYZ have been badly hit by recession and is taking a lot of cost cutting measures. Some of these measures include giving up office space, going open source, reducing incentives, cutting on luxuries and issuing pink slips.
They have got three (3) employees working in the accounts department and are going to lay-off two (2) of them. After a series of meetings, they have decided to dislodge the person who gets the most salary and the one who gets the least. This is usually the general trend during crisis like this.
You will be given the salaries of these 3 employees working in the accounts department. You have to find out the salary of the person who survives.
Input
The first line of input is an integer T (T<20) that indicates the number of test cases. Each case consists of a line with 3 distinct positive integers. These 3 integers represent the salaries of the three employees. All these integers will be in the range [1000, 10000].
Output
For each case, output the case number followed by the salary of the person who survives.
Sample Input Output for Sample Input
3 1000 2000 3000 3000 2500 1500 1500 1200 1800 | Case 1: 2000 |
完整代码:
/*0.013s*/
#include<cstdio>
#include<algorithm>
using namespace std;
int a[3];
int main()
{
int t;
scanf("%d", &t);
for (int i = 1; i <= t; ++i)
{
scanf("%d%d%d", &a[0], &a[1], &a[2]);
nth_element(a, a + 1, a + 3);
printf("Case %d: %d\n", i, a[1]);
}
return 0;
}
一家公司面临经济衰退,采取了包括裁员在内的多项成本削减措施。在会计部门中,将裁减两名员工,保留薪资既非最低也非最高的那一位。本文提供了一个算法解决方案,用于快速找出在三名员工中谁将被保留。
202

被折叠的 条评论
为什么被折叠?



