Regionals >> Asia-mudanjiang
Problem Link: UVALive6969 ZOJ3819 Average score. Basic training questions, written in C language.
Test instructions: There are n people in Bob's class (including Bob), and there are N people in the next class. If Bob is not in this class and joins the next class, the average of the two shifts will increase. Give Bob the n-1 individual scores and the next class M personal scores, ask Bob what the minimum and maximum value of the score.
Assuming Bob scores for X,bob and Suma, and for Sumb, the suma/(n-1) >= x >= sumb/(M + 1) must be met. Bob's results must be considered in the integer field, and the average score of the adjacent class is 1 points, which is 1 points less than the average of the class.
The following C language programs are adopted by AC:
/* UVALive6969 ZOJ3819 Average score */#include <stdio.h>int main (void) { int t, n, M, Suma, Sumb, Val, Min, Max, i; scanf ("%d", &t); while (t--) { scanf ("%d%d", &n, &m); suma = 0; for (I=1; i<=n-1; i++) { scanf ("%d", &val); Suma + = val; } Sumb = 0; for (I=1; i<=m; i++) { scanf ("%d", &val); Sumb + = val; } Min = sumb/m + 1; max = (suma% (n-1) = = 0)? Suma/(n-1)-1:suma/(n-1); printf ("%d%d\n", Min, max); } return 0;}
UVALive6969 ZOJ3819 Average Score