Choose the restaurant that maximizes your profit after accounting for the hunger of the customers and the restaurant's delay penalty.
N friends are going to have lunch. For the -th restaurant, you know two values:
Your actual profit from choosing restaurant is:
Your task is to find the maximum possible profit among all restaurants.
This is a direct evaluation problem: compute the profit for each restaurant and keep the best one.
Print one integer — the maximum value of over all restaurants.
Example 1
Input
3 8 1 4 4 5 2
Output
7
Explanation
The profits are 8-1=7, 4-4=0, and 5-2=3. The maximum is 7.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.