DOTAA - DOTA HEROES

Defence Of The Ancients (DOTA) is one of the most addictive online multiplayer games. There are n heroes in our team and our motto is to conquer the opponent’s empire. To safeguard their empire, the opponents had constructed m towers on the path. If one or more heroes get into the sight of a tower, then the tower does D amount of damage to one of those heroes at that instant (i.e. one of the heroes’ health decreases by D). Any hero will die if his health H <= 0. Once a tower attacks one of the heroes, all the heroes in the sight of that tower at that instant get out of its sight. Find whether all of the heroes in our team can reach the opponent’s empire alive.

Input

The first line consists of one integer t representing the number of test cases. For each test case, the first line consists of three integers n, m and D, the number of heroes, number of towers and the amount of Damage respectively. The next n lines consist of an integer representing the health of respective hero.

Output

Just a word “YES” if we can reach the opponent’s empire alive, else “NO”.

Constraints

1 <= t <= 500
1 <= n <= 500
1 <= m <= n
1 <= D, H <= 20000

Example

Input:
3
6 3 400
500
500
500
500
500
500
6 5 400
800
800
801
200
200
200
6 3 400
401
401
400
200
400
200

Output:
YES
NO
NO

Explanation of test case 1:

One of the possible solutions is: First, three of the heroes can goes together. One of them receives 400 damage from the first tower and all of them cross it. Then while crossing the next tower, one of the heroes who is at 500 health gets 400 damage and all of them cross it. Then the third hero receives the damage when crossing the last tower. Similarly the other 3 heroes can reach the opponent’s base together without dying.


Added by:cegprakash
Date:2011-12-25
Time limit:0.208s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: BF

hide comments
2015-08-21 21:21:53
Easy one... Just mind the upper case YES and NO. It cost me one WA
2015-08-13 09:10:41 Vars
AC in one go...just a close look on inputs & u r done with it :)
2015-08-09 18:21:41 Anurag Sharma
AC in 9th go... :P ..... hats off dotAA
2015-08-03 13:37:42 deerishi
Extremely Easy one! Don't overthink it.
2015-07-29 08:46:41 BadeMeow
"YES" and not "Yes" :P
2015-07-01 16:18:20
too easy .......simple logic............just notice the given testcases and u will get it
2015-05-30 14:17:14 xMAn
can sum1 tell me the ouput format clearly?
2015-05-29 21:43:32 Bhuvnesh Jain
half century...
2015-05-26 09:22:23 Narendra pal
is there an empty line between 2 input and 2 output...
2015-05-21 22:47:45 Rishabh Joshi
Nice time Constraints... Got TLE with ArrayList.Remove() method in C#.
Got TLE with sort() in C++. Both with O(n).
Maybe I was not implementing them right, but finally did in O(n) in C++.
Very easy logic tough.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.