![](http://acm.fzu.edu.cn/image/problem.gif)
Accept: 262 Submit: 553
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem 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
247703844 3748 3296 3390 475950001944 2353 4589 2386 3837
Sample Output
31661703
有点思维题的感觉
要让得奖的人最少,我们先让每个人只AC两道题目,如果AC两道题都不能平均分,那么肯定最少一个人都不能得奖,如果可以呢,我们就让AC5道题的人最多即可
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e6+7;
int num[10];
int main(){
int test;
cin>>test;
while(test--){
int n;
cin>>n;
int sum=0;
for(int i=1;i<=5;i++){
scanf("%d",&num[i]);
sum+=num[i];
}
if(sum<=2*n) cout<<0<<endl;
else{
int a,b;
a=b=0;
sum-=2*n;
a=sum/3;
b=sum%3;
if(b>0) b=1;
a+=b;
cout<<a<<endl;
}
}
}