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)
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])
printf("Data Set %d:\n%d\n\n", I, ans+1);

Solution Stats

33.33% Correct | 66.67% Incorrect
Last solution submitted on Dec 13, 2014
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!