Description
好久没举月赛了,这次lqw给大家出了5道题,因为hsy学长宣传的很到位,吸引了n个DDMM们来做,另一位kk学长说,全做对的要给金奖,做对4题要给银奖,做对3题要给铜奖。统计数据的时候,发现每题分别在n个人中有n1、n2、n3、n4、n5个人通过,lqw灵机一动,问kk:“你猜,这次至少会有多少个人获奖?”由于题目太简单了,每题的通过人数一定大于等于最低获奖人数。
Input
第一行一个数字t,表示有多少组数据,每组数据如下所示(1000 < t < 5000, 100<=n<=1000000, n1,...,n5<=n):
n
n1 n2 n3 n4 n5
Output
针对每组数据,输出一个数,表示最低获奖人数。
Sample Input
2 4770 3844 3748 3296 3390 4759 5000 1944 2353 4589 2386 3837
Sample Output
3166 1703
解题思路:因为最少AC3题可以获奖,所以首先让n个人每人AC2题,然后将总的AC题数减去n个人AC2题的题数,后将差值整除3,因为要得到最少的获奖人数,所以就假设得奖的都是金奖,如果有余数,说明还会多出1、2道题目无法成金奖,就加1就行。
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int n1,n2,n3,n4,n5;
scanf("%d%d%d%d%d",&n1,&n2,&n3,&n4,&n5);
int m=n1+n2+n3+n4+n5;
int tmp;
tmp=m-n*2;
if(tmp<=0){
printf("0\n");
}else{
if(tmp%3==0){
printf("%d\n",tmp/3);
}else {
printf("%d\n",tmp/3+1);
}
}
}
return 0;
}