codeforces-scrape

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

54A.md (1914B)


      1 Source: https://codeforces.com/problemset/problem/54/A
      2 
      3 A. Presents
      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 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 The Hedgehog likes to give presents to his friend, but no less he likes to receive them.
     22 
     23 Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, but which one should he choose, how large should it be?
     24 
     25 In order to get to know this, the Hedgehog asks you to write him a program that will count the estimated number of presents that he will receive during the following *N* days. Besides, he is guided by the principle:
     26 
     27 * on each holiday day the Hedgehog will necessarily receive a present,
     28 * he receives presents at least every *K* days (i.e., if he received a present on the *i*-th day, he will receive the next present no later than on the *i* + *K*-th day).
     29 
     30 For the given *N* and *K*, as well as the list of holidays among the following *N* days count the minimal number of presents that could be given to the Hedgehog. The number of today's day is zero, and you should regard today's present as already given (i.e., you shouldn't count it in the answer).
     31 
     32 Input
     33 
     34 The first line contains integers *N* and *K* (1 ≤ *N* ≤ 365, 1 ≤ *K* ≤ *N*).
     35 
     36 The second line contains a number *C* which represents the number of holidays (0 ≤ *C* ≤ *N*). Then in the same line follow *C* numbers ranging from 1 to *N* which are the numbers of holiday days. The numbers are given in the increasing order, without repeating numbers among them.
     37 
     38 Output
     39 
     40 Print a single number — the minimal number of presents the Hedgehog will receive over the following *N* days.
     41 
     42 Examples
     43 
     44 Input
     45 
     46 ```
     47 5 2  
     48 1 3
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 3
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 10 1  
     61 3 6 7 8
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 10
     68 ```