码迷,mamicode.com
首页 > 其他好文 > 详细

fzu 2138

时间:2014-11-20 01:23:56      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   io   ar   os   sp   for   strong   

A - 久违的月赛之一
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Appoint description: 

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

FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
All Copyright Reserved ©2010-2014 HUST ACM/ICPC TEAM 
Anything about the OJ, please ask in the forum, or contact author
因为要求最小,所以假设每个人都做出两道题,然后最后 将3道题分配就好了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<set>
using namespace std;
int t,n,a[5],sum,res;
int main()
{
      scanf("%d",&t);
      while(t--)
      {
            sum=0;
            scanf("%d",&n);
            for(int i=0;i<5;i++)
            {
                 scanf("%d",&a[i]);
                 sum+=a[i];
            }
            res=sum-2*n;
            if(res<0)
                  printf("0\n");
            else
            {
                  if(res%3==0)
                        res=res/3;
                  else
                        res=res/3+1;
                  printf("%d\n",res);
            }
      }
      return 0;
}

  

fzu 2138

标签:des   blog   http   io   ar   os   sp   for   strong   

原文地址:http://www.cnblogs.com/a972290869/p/4109591.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!