FOJ 2013 11 月赛 H
Problem 2139 久违的月赛之二
Accept: 28 Submit: 66 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,表示有多少组数据,每组数据如下所示(100< t < 300, 10<=n<=100, n1,...,n5<=n):
n
n1 n2 n3 n4 n5
Output
针对每组数据,输出一个数,表示最低获奖人数。
Sample Input
2 92 76 72 72 53 92 81 70 81 45 63 64
Sample Output
64 58
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 int a[11]; 6 int main(){ 7 int t,s,n; 8 scanf("%d", &t); 9 while (t--){ 10 scanf("%d", &n); 11 for (int i = 0; i < 5; i++)scanf("%d", &a[i]); 12 for (int i = 0; i <= n; i++){ 13 s = 0; 14 for (int j = 0; j < 5; j++){ 15 s += max(a[j] - i,0); 16 } 17 if (s <= 2 * (n - i)){ printf("%d\n", i); break; } 18 } 19 } 20 return 0; 21 }
浙公网安备 33010602011771号