fzu Problem 2138 久违的月赛之一

来源:互联网 发布:数控编程实例讲解 编辑:程序博客网 时间:2024/06/06 02:25

1、http://acm.fzu.edu.cn/problem.php?pid=2138

2、题目:此题居然是个贪心的题目

Problem 2138 久违的月赛之一

Accept: 73    Submit: 137
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

3、ac代码:

#include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>using namespace std;int a[10];int main(){    int n,t;    while(scanf("%d",&t)!=EOF)    {        while(t--)        {            scanf("%d",&n);            int sum=0;        for(int i=0;i<5;i++)        {            scanf("%d",&a[i]);            sum+=a[i];        }        if(sum<=2*n)        printf("0\n");        else        {            int tmp=sum-2*n;            int ans1=tmp/3;            if(tmp%3!=0)            ans1+=1;            printf("%d\n",ans1);        }        }    }    return 0;}


 

原创粉丝点击