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
2014-03-13 19:22:01 Anirudh Goyal
STILL I am getting wrong answer PLEASE TELL SOME TEST CASES and answer for these cases
6 6 400
500
500
500
500
500
500

and 6 1 400
1200
500
500
500
500
500
So please give some more cases don;t know why I'am getting wrong answer

Last edit: 2012-06-17 13:51:45
2014-03-13 19:22:01 :D
Problem description is a little confusing.

Last edit: 2019-12-06 21:43:56
2014-03-13 19:22:01 vishal chaudhary
do i have to check the heroes in the order of their input or ...can i just check the heroes with more life first for the towers...so that they can pass [spoiler]...??...plz help..


Last edit: 2019-12-06 21:44:57
2014-03-13 19:22:01 Abhay Mangal
What if heroes carry some salves? :P xD

Author : Adding salves would be a good upgraded problem.

Last edit: 2019-12-06 21:46:43
2014-03-13 19:22:01 Yoga Pratama A
why always runtime error SIGSEGV..??
2014-03-13 19:22:01 Sandy Akbar Dewangga
very easy :)
2014-03-13 19:22:01 Ali Arous
When you read the comments you think that you don't have to think , but you have to if you don't want to get WA's
2014-03-13 19:22:01 Harsh Thakar
@Saket - More test cases would just ruin the problem
2014-03-13 19:22:01 Rachmawan Atmaji Perdana
One more easy problem to solve. Thanks
2014-03-13 19:22:01 saket diwakar
getting again and again wrong answers....
no doubt finally got AC.:)

Last edit: 2012-02-13 14:03:36
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.