City Travel
Practice
3.9 (156 votes)
Basic programming
Basics of implementation
Easy
Implementation
Problem
78% Success 54569 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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.

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:10
41 votes
Tags:
AlgorithmsSortingString Manipulation
Points:10
185 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyImplementationOpen
Points:10
82 votes
Tags:
Basic ProgrammingBasics of ImplementationImplementation