Busy Airport
Practice
3.5 (6 votes)
C++
Sorting
Advanced sorting
Algorithms
Problem
79% Success 1360 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Checkout at an airport consists of two sequential events first passport check which takes time \(A\) minutes and there are \(B\) counters present for it. Second is luggage check which takes \(C\) minutes and there are \(D\) counters present for it.

Functioning of different counters is independent of each other and every passengers must go through both events in order i.e. first passport then luggage check.

Given \(N\) passengers and their arrival time \(A[i]\). Find the minimum time in which all the passengers will get their both events done.

Input format

  • First line contains \(4\) space separated integers denoting \(A \ B \ C\ D\)
  • Next line contains \(N\), denoting number of passengers
  • Next line contains \(N\) space separated integers, denoting arrival times of passengers (in sorted order)

Output format

Print a single integer denoting the minimum time required to get all passengers done with both events.

Constraints

\(1 \le A, C \le 10^9 \\ 1 \le N, B , D \le 10^5 \\ 1 \le A[i] \le 10^9 \\ A[i-1] \leq A[i]\)

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
7 votes
Tags:
AlgorithmsMedium
Points:30
6 votes
Tags:
SortingAlgorithmsAdvanced Sorting
Points:30
2 votes
Tags:
AlgorithmsSortingAdvanced Sorting