F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Climb Stairs

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1589    Accepted Submission(s): 717


Problem Description
DLee came to a new level. What is waiting for him is a tall building with $n$ floors, with a monster on each stair, the $i$-th of which has health point $a_i$.

DLee starts from the ground(which can be regarded as the 0-th floor), with a base attacking point $a_0$. He can choose to jump $1,2,\dots,k$ floors up or walk $1$ floor down, but he cannot go to floors whose monster has a health point strictly greater than his attacking point, nor can he go to floors which had been visited. Once he comes and defeats a monster he can absorb his health point and add it to his attacking point.

Note that DLee should always be on floors $\{0,1,2,3,\dots,n\}$.

Now DLee asks you whether it is possible to defeat all the monsters and pass the level.
 

Input
There are $T$ test cases.

In each test case, the first line contains three integers: $n,a_0,k(1\leq n,k\leq 10^5,1\leq a_0\leq 10^9)$, representing the number of floors, base attacking point, and the maximum number of floors that DLee can jump.

The second line contains $n$ integers $a_1,\dots,a_n(1\leq a_i\leq 10^9)$, representing the health point of each monster.

The sum of $n$ does not exceed $10^6$.
 

Output
For each test case, output "YES" or "NO" to show whether it's possible to defeat all monsters.
 

Sample Input
4 6 1 4 2 2 1 1 9 3 4 2 2 2 3 8 1 3 1 2 3 1 2 7 2 3 4 3 2 7 20 20 20
 

Sample Output
YES YES NO NO
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 01:53:33, Gzip enabled