This page is still under construction.

Parts of this page are still being built. What you see may change.

Toxic Barrier

Time limit1sMemory limit128 MB

Summary
Find the convex hull of N points and add a buffer of distance L around it, giving the minimum closed barrier length rounded to the nearest integer.
Level

Medium6 of 10

Topics
Geometry, Sorting, Math, Implementation
Solved
No attempts yet

Problem

Seongjun, king of the Chemical Empire, decided to build his nation's pride — a chemical barrier — to finally be free from the repeated invasions of neighboring countries. The barrier releases a toxin harmful to any creature that comes near, so that no other nation dares to approach.

However, the barrier is difficult to construct, so it must be made as short as possible. It can also harm the king's own people, so it must always stay at a distance of at least LL from every building in the country.

Given the coordinates of the country's buildings, find the minimum length of a barrier that encloses all of the buildings at once while keeping a distance of at least LL from every building.

Input

The first line contains the number of buildings NN and the distance LL. (3≤N≤10003 \le N \le 1000, 1≤L≤10001 \le L \le 1000; NN and LL are integers.)

Each of the next NN lines contains the integer coordinates XiX_i and YiY_i of a building. (−10000≤Xi,Yi≤10000-10000 \le X_i, Y_i \le 10000) All building coordinates are distinct, and each building is small enough to be treated as a single point. The barrier must not cross itself and must not be broken.

Output

Print, on the first line, the minimum length of the barrier that encloses all buildings, rounded to the nearest integer.

Examples1

  1. Example 1

    Input
    9 100
    200 400
    300 400
    300 300
    400 300
    400 400
    500 400
    500 200
    350 200
    200 200
    
    Expected output
    1628