This Challenge is to solve the USC Spring 2013 ACM Contest Problem A, Relief Supplies.
The theme for Spring 2013 is Snowstorm.
Summary of Challenge is to Optimize your family's most needed Relief Supplies while never being the sole maximum distribution receiver of your preferred item.
Distribution is to N families; T items; quantity B of each item; Selected item is S. 2<=N<101; S<=T; 1<=B,T<101
Distribution of T=5 and B=2 to 10 families would be 1 2 3 4 5 1 2 3 4 5. Distribution of items cycle.
Return the Position in Line of N families that is the last to receive the second most of your selected item or the last to receive the most of the item if multiple families receive this maximum amount.
Input NTSB: 4 6 3 5 Output: 3
Input NTSB: 4 3 6 1 Output: 4
Winner Cao's C solution (15 minutes): "For Loops - tsk tsk"
for (int i=0;i<b;++i)
for (int j=0;j<t;++j)
{
if (j==s-1)
{
a[tot%n]++;
}
tot++;
}
for (int i=0;i<n;++i)
c[i] = a[i];
sort(a, a+n);
int ans = 0;
for (int i=0;i<n;++i)
if (c[i]==a[n-2])
ans=i;
printf("Data Set %d:\n%d\n\n", I, ans+1);
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1328 Solvers
-
118 Solvers
-
Back to basics 16 - byte order
202 Solvers
-
514 Solvers
-
Simple date to serial no. conversion
134 Solvers
More from this Author306
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I believe the problem description has an error. There are two examples given at the end of the description, and they are given as "Input NTSB". Should be "Input NTBS".