Question: Please use C + + , and the limits of the all testcaset are under 1 second and under 6 4 MB . And 0
Please use C and the limits of the all testcaset are under second and under MB
And xi yi D N There are subtasks: For subtask : N For subtask : N For subtask : N
DSHWStack&Queue
Description There are N particles moving from right to left, each moving at a constant speed of one unit per second. The position of the particles can be represented using a Cartesian coordinate system. All particles will disappear when they reach the xaxis at position TA has invented a board that can absorb the energy of these particles. The board is fixed vertically at the xaxis at position but its position on the yaxis can be adjusted, and its length can also be modified before being finally fixed. Once the location and length of the board are determined, they cannot be changed. The board can successfully absorb energy under one condition: the time interval between the absorption of the first particle and the last particle must be at least D seconds. Otherwise, the absorption will fail. Due to cost considerations, TA hopes to minimize the length of the board. Please find the minimum length needed to satisfy the above condition. if it is not possible, please output Note: The edges of the board are also considered part of the board and can absorb particles. If you use C you can add ios::syncwithstdio; and cin.tie; to speed up input. In HW you can use std library.Input The first line of input contains two integers, N and D The following N lines each represent the coordinates of a particle xi yi All inputs are integers. Guarantee that the input of particle coordinates is sorted according to the Yaxis. xi yi D N There are subtasks: For subtask : N For subtask : N For subtask : N Output Please output an integer representing the minimum length of the board. If there is no board that meets the conditions, please output Sample Input : Sample Input :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
