Zaporozhets Limousine
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian. In case of any discrepancy, the Ukrainian version is authoritative.
Soon, the semi-finals of the World Programming Championship will take place. Due to the burdock virus pandemic, the members of the Lviv University teams decided to travel using their own transport. For this purpose, the team coaches bought a Zaporozhhets limousine!
However, a difficult path awaits our heroes, namely a road with \(n\) potholes located sequentially, each with a depth of \(h_i\). The limousine loses one wheel when it drives into a pothole with a depth strictly greater than \(k\). Since the driver obtained their license only this year, they can bypass at most \(x\) potholes. The limousine stops and does not continue its movement if strictly more than one wheel falls off.
Since our heroes are busy buying juice for the road, help them find out if they will be able to reach their destination without forced stops.
Input
The first line contains three integers \(n\), \(k\), \(x\) — the number of potholes on the road, the maximum allowable pothole depth, and how many potholes the driver can bypass.
The next line specifies \(n\) integers \(h_i\) — the depth of the \(i\)-th pothole.
Output
Print YES if our heroes can reach their destination,
otherwise print NO.
Constraints
\(1 \le x \le n \le 10^5\),
\(1 \le h_i, k \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 7 4 4 5 1 2 8 6 7 9 | YES |
| Input (stdin) | Output (stdout) |
|---|---|
| 4 2 1 3 3 4 1 | NO |
Notes
In the first example, the driver can bypass 4 potholes (for example, the potholes with depths 5, 8, 6, 7) and, having lost one wheel, still reach the destination.
In the second example, there are 3 potholes with a depth strictly greater than 2, and only 1 can be bypassed, so, unfortunately, our heroes will not reach their destination.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|