codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1059A.md (1703B)


      1 Source: https://codeforces.com/problemset/problem/1059/A
      2 
      3 A. Cashier
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Vasya has recently got a job as a cashier at a local store. His day at work is $L$ minutes long. Vasya has already memorized $n$ regular customers, the $i$-th of which comes after $t_{i}$ minutes after the beginning of the day, and his service consumes $l_{i}$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer.
     22 
     23 Vasya is a bit lazy, so he likes taking smoke breaks for $a$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
     24 
     25 Input
     26 
     27 The first line contains three integers $n$, $L$ and $a$ ($0 \le n \le 10^{5}$, $1 \le L \le 10^{9}$, $1 \le a \le L$).
     28 
     29 The $i$-th of the next $n$ lines contains two integers $t_{i}$ and $l_{i}$ ($0 \le t_{i} \le L - 1$, $1 \le l_{i} \le L$). It is guaranteed that $t_{i} + l_{i} \le t_{i + 1}$ and $t_{n} + l_{n} \le L$.
     30 
     31 Output
     32 
     33 Output one integer  — the maximum number of breaks.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 2 11 3  
     41 0 1  
     42 1 1
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 3
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 0 5 2
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 2
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 1 3 2  
     67 1 2
     68 ```
     69 
     70 Output
     71 
     72 ```
     73 0
     74 ```
     75 
     76 Note
     77 
     78 In the first sample Vasya can take $3$ breaks starting after $2$, $5$ and $8$ minutes after the beginning of the day.
     79 
     80 In the second sample Vasya can take $2$ breaks starting after $0$ and $2$ minutes after the beginning of the day.
     81 
     82 In the third sample Vasya can't take any breaks.