Sort the concentration of the potion. If the concentration is smaller than the concentration of the solution water, you can directly add its volume to record the concentration of the potion after each mixture,
If it is greater than the concentration of the solution water, it is output. Pay attention to whether it is a percentage or a percentage...
# Include <stdio. h>
# Include <algorithm>
# Include <iostream>
# Include <string. h>
Using namespace STD;
Int s [10005];
Int main ()
{
Int A, I, n, m, K;
Scanf ("% d", & );
While (--)
{
Scanf ("% d", & N, & M, & K );
For (I = 0; I <n; I ++)
{
Scanf ("% d", & S [I]);
}
Sort (S, S + n );
If (s [0]> K)
{
Printf ("0 0.00 \ n ");
Continue;
}
Double sum1, sum = 0, DD;
Int ans = 0;
For (I = 0; I <n; I ++)
{
If (s [I] <= K)
{
Sum1 = (double) m * s [I]/100.0;
Sum = (double) (sum1 + sum * ans)/(ANS + M) * 1.0;
Ans + = m;
}
Else
{
Sum1 = (double) m * s [I]/100.0;
Dd = sum;
Sum = (double) (sum1 + sum * ans)/(ANS + M) * 1.0;
If (sum * 100> K)
{
Printf ("% d %. 2lf \ n", ANS, DD );
Break;
}
Else
{
Ans + = m;
}
}
}
If (I = N)
Printf ("% d %. 2lf \ n", ANS, sum );
}
Return 0;
}