One of the long-lost month racesTime
limit:1000MS
Memory Limit:32768KB
64bit IO Format:%i64d &%i64 U SubmitStatusPracticeFzu 2138
Description
For a long time did not raise the month race, this lqw to everyone out of 5 questions, because HSY seniors propaganda is in place, attracted n ddmm to do, another KK seniors said, all do to the gold medal, do 4 to give silver, do 3 to the Bronze award. Statistics of the time, found that each of the questions in the N individuals have N1, N2, N3, N4, N5 individual through, LQW Brainwave, asked KK: "You guess, at least how many people won?" Because the topic is too simple, the number of passes per question must be greater than or equal to the minimum number of winners.
Input
The first line is a number T, which indicates how many sets of data, each set of data is shown below (< T < 100<=n<=1000000, N1,..., n5<=n):
N
N1 n2 N3 N4 N5
Output
For each set of data, output a number that represents the lowest winning number.
Sample Input
2 4770 3844 3748 3296 3390 4759 5000 1944 2353 4589 2386 3837
Sample Output
3166 1703
Problem-solving ideas: Because at least AC3 title can be won, so the first to let n individual AC2, and then the total number of AC problems minus n AC2 questions, after the difference is divisible by 3, because to get the least number of winners, so assume that the prize is the gold medal, if the number of surplus, it will be more than 1, 2 questions can not be a gold medal, add 1 on the line.
#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;}
Fzu 2138--One of the long-lost month race —————— "greedy"