You are going from City A to City B. The distance between A and B is \(S\) km. In the most days, you can go at most \(X\) km one day. But there are \(N\) exceptions, in the \(T_i\) th day, you can go at most \(Y_i\) km. You need to find out the minimum number of days required to reach city $$B$$ from city $$A$$.
Input Format
First line contains three integers, \(S,X,N (1\le S,X\le 10^9,0\le N\le 10^3)\).
The \((i+1)\) th line contains two integers \(T_i,Y_i(1\le T_i,Y_i\le 10^9)\).
It's guaranteed any two \(T_i\) are different. Note that \(T_i\) is not sorted.
Output Format
One integer represents the answer.
In the first day, you walked \(5\)km.
In the second day, you walked \(4\)km.
In the third day, you walked \(5\)km.
In the fourth day, you walked \(7\)km and arrived.
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
Login to unlock the editorial
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