2 kingdom are at war.kingdom 1 has N soldiers (no. As 1 to N) & war goes on for K days.each day only 1 solider can be select. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

2 kingdom are at war.kingdom 1 has N soldiers (no. As 1 to N) & war goes on for K days.each day only 1 solider can be select.

kingdom 1 can select 1 solider frm Ni to Nj.Ni &Nj are provided to you for each day selection criteria:each solider has 2 parameter i.e A&B.A is selected if A is max.If more the one solider has A max then soldier wid min B (of shortlisted soldiers) is selected. If more then one soldier is still remaining then the solider with least index (of shortlisted solidr) is selected.Print the solider no selected for each day of war. can anyone plz send me algorithm or c++ or java code! ☺

8th Mar 2017, 9:47 AM
priyanshi srivastava
priyanshi srivastava - avatar
3 Answers
+ 16
This is a homework... I do not actually why has the soldier two parameters...
25th Mar 2017, 7:38 AM
Gami
Gami - avatar
+ 13
Sorry, first have to write it down again to understand it. 2 kingdoms are at war. - kingdom1 has N soldiers (relation 1 to N) - war lasts k days. - each day only 1 soldier can be selected - kingdom1 can select 1 soldier from Ni to Nj. - Ni & Nj are provided to you for each day selection criteria: - each soldier has 2 parameters i.e A and B. - A is selected if A is max. - if more than one soldier has A max then soldier with min B (of shortlisted soldiers) is selected. - if more than one soldier is still remaining, the soldier with least index (of shortlisted soldier) is selected. Print the selected no. of the soldier for each day of war.
24th Mar 2017, 10:24 PM
Tashi N
Tashi N - avatar
+ 12
Yeah, I think so, too. Priyanshi, what have you done so far? Could you publish your code?
25th Mar 2017, 7:41 AM
Tashi N
Tashi N - avatar