1 / 12

HKOI 2014 Senior

HKOI 2014 Senior. Pharmaceutical Company Problem Prepared by : Gary Wong. Problem. Find the maximum number of capsules they can produce Find the earliest possible time for the workers to finish the synthesis process in such case. Solution 1. Write a function to achieve this

amalie
Télécharger la présentation

HKOI 2014 Senior

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HKOI 2014 Senior Pharmaceutical Company Problem Prepared by : Gary Wong

  2. Problem • Find the maximum number of capsules they can produce • Find the earliest possible time for the workers to finish the synthesis process in such case

  3. Solution 1 • Write a function to achieve this • given the time the workers finished the synthesis work, find the number of capsules they can produce • Exhaust the finishing time for X workers, from 1 to T • Complexity = O( T * ( X + Y ) ) • Score = 50 

  4. Observation 1 • If the synthesis process is too long, the Y workers cannot finish the capsuling process • If the synthesis process is too short, the number of capsules will not be maximized • There must be a critical time slot (s – t), such that • More than t units of time, the capsuling process cannot be finished • Less than s units of time, the number of capsules will not be optimal

  5. Possible Idea 1 • One might use binary search to locate one terminal of that time slot t • Is t units of time the answer?

  6. Tricky Part • In that time slot, the number of capsules can be produce might be identical • Recalled from the problem statement • “If there are multiple solutions that can maximize the number of capsules, output the earliest time for the shift” • Obviously finding t is not good enough • What should we do to find s?

  7. Possible Idea 2 • After the binary search, we’ve already known the optimal number of pills we can make • Studying the property of s • Using less than s units of time, the number of pills apparently is not maximum • Using time from s to t, the number of pills is identical • In other words, s is another critical point

  8. Solution 2 • Write a function to achieve this • given the time the workers finished the synthesis work, find the number of capsules they can produce • Use binary search to locate t from 1 to T • Use binary search to locate s from 1 to t • Complexity = O((X + Y) ln T) • Score = 100

  9. Observation 2 • Using two binary search is not convenient enough • For example, • X = 1, he need 3 units of time to produce a pill • Giving him 3, 4, 5 units of time, the number of pill he could produce is same • Once we locate the time of t • Find x = min(t mod Ta[i]) • The optimal time is actually t - x

  10. Solution 3 • Write a function to achieve this • given the time the workers finished the synthesis work, find the number of capsules they can produce • Use binary search to locate t from 1 to T • Find the minimum modulus • Output t – x and the pills can be made • Complexity = O((X + Y) * ln T) • Score = 100% 

  11. Tricky Case • If the time is only enough to produce 0 pill, what should we output? • (0, 0)? • No! • As the boss is very mean, X workers need to prepare and clean up before Y workers arrive 

  12. END

More Related