Submeter | Todas submissőes | Melhores | Voltar |
M0219 - Mountain Ranges |
Famous for its mountain ranges, Nlogonia attracts millions of tourists every year. The gov-ernment has a dedicated budget for continuous maintenance of the hiking trails spread across the country and most of them are filled with scenic viewpoints, accessible through wooden walkways and stairs.
Currently on a trip through Nlogonia and with hopes of going back home with lots of breath-taking pictures, Lola and her husband want to visit as many viewpoints as possible. They plan to hike a different trail each day and explore its viewpoints. However, to avoid being exhausted at the end of the day, if moving from one viewpoint to the next requires going up more than X meters they simply call it a day and go back to their hotel in order to get some rest. Fortunately, every hiking trail in Nlogonia is equipped with modern chairlifts, so the couple can start hiking the trail at any viewpoint they decide. Once the hiking begins the couple only moves towards the peak of the mountain.
To make sure she doesn’t waste a day Lola only wants to hike on trails where she’ll get to a reasonable number of viewpoints. Given the altitudes of the scenic viewpoints on a hiking trail, you must determine the maximum number of viewpoints that the couple can visit.
Entrada
The first line contains two integers N (1 ≤ N ≤ 1000) and X (0 ≤ X ≤ 8848), indicating respectively the number of scenic viewpoints on the hiking trail, and the maximum number of meters that Lola and her husband are willing to go up from one viewpoint to the next. The second line contains N integers A1 , A2 , . . . , AN (1 ≤ Ai ≤ 8848 for i = 1, 2, . . . , N ), where Ai is the altitude (in-meters) of the i-th viewpoint. Viewpoints are given in the order they appear on the hiking trail and their altitudes are non -decreasing, that is, Ai ≤ Ai+1 for i = 1, 2, . . . , N − 1.
Saída
Output a single line with an integer indicating the maximum number of scenic viewpoints that can be visited without going up more than X meters from one viewpoint to the next, and considering that the journey can be started at any viewpoint.
Exemplo
Entrada: 9 2 3 14 15 92 653 5897 5897 5898 5900 Saída: 4
Entrada: 9 0 3 14 15 92 653 5897 5897 5898 5900 Saída: 2
Entrada: 9 8848 3 14 15 92 653 5897 5897 5898 5900 Saída: 9
Adicionado por: | IFTM_Maratona |
Data: | 2022-10-31 |
Tempo limite: | 1s |
Tamanho do fonte: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Linguagem permitida: | C NCSHARP C++ 4.3.2 JAVA JULIA PYTHON3 |
Origem: | Maratona SBC 2Fase AD-HOC |