There are n urban communities numbered from 1 to n, and city I has excellence computer based intelligence. A sales rep needs to begin at city 1, visit each city precisely once, and return to city 1. For all i≠j, a departure from city I to city j costs max(ci,aj−ai) dollars, where ci is the value
Correct answer will be upvoted else downvoted. Computer science.
There are n urban communities numbered from 1 to n, and city I has excellence computer based intelligence.
A sales rep needs to begin at city 1, visit each city precisely once, and return to city 1.
For all i≠j, a departure from city I to city j costs max(ci,aj−ai) dollars, where ci is the value floor implemented by city I. Note that there is no outright worth. Track down the base absolute expense for the sales rep to finish his excursion.
Input
The main line contains a solitary integer n (2≤n≤105) — the number of urban communities.
The I-th of the following n lines contains two integers
Output
Output a solitary integer — the base all out cost
Step by step
Solved in 3 steps with 1 images