Page 1 of 1

וב Х main (5).pdf - Adobe Reader File Edit View Window Help Due Date 1 The Problem You are running for political office.

Posted: Fri Apr 29, 2022 7:04 am
by answerhappygod
 1
1 (130.61 KiB) Viewed 28 times
וב Х main (5).pdf - Adobe Reader File Edit View Window Help Due Date 1 The Problem You are running for political office. Your goal is to recruit as many volunteers as possible from kwestions, ...., around the city. Your brillia campaign manager as determined that kuation &, can yield 4 new volante, hut only if you send volunteers. Additionally, your campaign manager inform you that you only have the haiget to recruit from k locations! Initially, you have u volunteers. After successfully recruiting from city & you will have to volunteers. , , o . You may choxe from wo de lost from which laruit. Devise a greedy algorithm to output the maximum possible number of voltantoets. Your algorithm should have a ritime of On logn). 2 Writeup (50 Points) You • design a greedy algorithm that solve this problem in worst case in logr) time • prove the algorithm's G Tuntime give pecade 3 Source Code (50 Points) • Write your solution in C, C++, Jawa, JamScript, or Python • Your code should be well written and well commented • Alter pusting your code, you will automatically see which test cas passed and how many points you hawered • Up to the deadline, you can resubmit your code as many times as necessary without penalty 3.1 Input Format The first line contains three integers nk, and the number of locations, the maximum number of possible locations you may visit, and the initial number of wolunteers, respectively. The next line consists of the space separated values ....... the number of volunteers that can be rerutelsat location The final line consists of the space separnted wlues . ---, V, the minimum number of wohntes required to recruit the volunteers at location & You may assume all inputs are valid. 3.2 Output Format Output the maximum posible number of volunteers that can be recruited I Type here to search 대 43°C Haze AVOUE ENG 4:45 PM 4/26/2022
וב Х main (5).pdf - Adobe Reader File Edit View Window Help 3.2 Output Format Output the maximum posible number of volunteers that can be recruited 3. Constraints You are given that G 15ks 10 DSS10 OS 10 All answers is within a 64 bit integer, 3.1 Example 1 3.4.1 Input Input Output 1 320 123 011 3.4.2 Explanation Initially, we have a volunteers, so we can only recruit from location. After recruiting from to, we have 0+1=1 volunteers. Since k = 2, we can recruit from one more location, so we choose the best one. . k = 2, at location 1. This totals 0+1+3 = 4 volunteers 3.5 Example 2 3.1.1 Input loput Output 3 2 1 123 012 I Type here to search 대 43°C Haze AVOUE ENG 4:46 PM 4/26/2022