Quals-I-2011-3
The Will Rogers phenomenon is obtained when moving an element from one set to another set raises the average values of both sets. It is based on the following quote:
When the Okies left Oklahoma and moved to California, they raised the average intelligence level in both states.
You are given two sets of non-negative integers a and b, of sizes n and m, respectively. You should find how many number from the set a raise the average of the both sets when moved to the set b.
InputIn the first line of the standard input you will be given n and m (2 <= n, m <= 5000). The next two lines contains n and m non-negative integers, respectively, that represent the sets a and b. Each element from the sets is within the interval [1, 1000].
OutputOn the first and the only line of the standard output print the number as explained in the problem statement.
Input:
Output:
Explanation:
The only element that satisfies the conditions is 4.
3 3
6 5 4
1 2 3Output:
1Explanation:
The only element that satisfies the conditions is 4.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.