solution

Solve C++ language

You all have heard about the brave warrior Hashmat, right? Last time you saw him, he was fighting with a group of soldiers. But this time he is alone. Who needs an army if you can gain all the strength of your opponent after vanishing him! Hashmat is going to conquer a city, alone. He has to face N opposing soldiers to enter the city.
He has an initial strength P.
The soldiers will come to him in the order they are given. He can only kill a soldier if his strength is greater or equal to that soldier.
After he kills a soldier, he takes all of its strength and becomes more powerful.
If he faces a soldier that has greater strength than him, he uses a special weapon to kill that soldier instantly, in this case Hashmat’s strength does not increase.
So far he can conquer the city easily, can he? Not yet. He can only use the special weapon K times. Given the data, can you say if he can conquer the city or not?
Input
First line of the input gives you three integers, N, P and K, where N (1 5 N s 105) is the number of soldiers that Hashmat faces, P O S P < 106) is the initial strength of Hashmat and K (0 = K = N) is the number of times he can use the special weapon.

Next line gives an array A of N integers, representing the strength of the soldiers sequentially. Where for each i (13i3N), O SA < 106.

Output
Print a single line containing a string that says “YES”, if Hashmat can conquer the city, and “NO” otherwise. Print the strings without the quotations, and don’t forget to print a newline.

Input
1 5 4 2
2 3 6 7 25 19
3
Output
1 YES
2

Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp