The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
A country has N cities with certain population in each city. These cities are internally connected by two-way power cables. Among them, K cities have powerhouses. If a powerhouse is in a city, or is connected to another city via cables, directly or indirectly, you can provide electricity to that city, if you own the powerhouse.
Initially X (X=K) of the powerhouses are owned by you. Each powerhouse costs something, and the cost is given to you. You can sell any power house that you own, at the cost of the powerhouse. You can buy a powerhouse which you don’t yet own, at it’s mentioned cost, if you have enough money.
In your bank account you have some money, say M (apart from the powerhouses you own).
You want to satisfy maximum number of people, by buying and selling appropriate powerhouses. Find the maximum number of people that can be satisfied.
One integer in a single line denoting the maximum number of people that you can satisfy.
Input: 6 6 2 1 2 1 3 1 4 2 4 3 4 5 6 5 3 11 7 2 18 4 5 115 100 1 14 2 Output: 20
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll