Problem 1438. USC Spring 2013 ACM: Relief Supplies
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
-
1 Comment
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".
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
27557 Solvers
-
266 Solvers
-
17109 Solvers
-
10027 Solvers
-
Create a function handle that reverses the input arguments of another function handle
150 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!