Блог пользователя jerseyguy

Автор jerseyguy, история, 5 лет назад, По-английски

Can somebody give some hints? problem name : students council ( from cf edu section)

Regards.

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
  • First of all if we need to build x councils each consists of k students, then from each group we can take atmost x students. So in the end if we get more than (x*k) students from the group we can build x coucils.

*In this problem we need to maximize the number of councils we need to search for that maximum value of x that satifies the given condition.

*In the worst case the total councils may be 0 and in the best case total councils may be (sum of students/k), so we need to search the maximum value between these two numbers.

*the trend its shows will be T,T,T,F,F,F.. we need to find the last true. so I applied binary search and it got accepted.

//sorry for my bad english

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

You can note that if you can form K > 1 councils, then you can form K — 1. So binary search will help.

possible(m) tell us if is possible to form at least m councils.

To construct possible(m) here is a hint:

sort groups by size, then find out if you can apply a greedy algorithm.