import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) throws IOException{
InputReader in = new InputReader(System.in) ;
StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt() , r = in.nextInt() ;
P[] p = new P[n] ;
for(int i = 0 ; i < n ; i++) p[i] = new P(in.nextInt() , in.nextInt()) ;
out.printf("%.0f", new Task().solve(p , r) ) ;
out.flush() ;
}
}
class Task{
public double solve(P[] p , int r){
double res = 0 ;
P[] qs = convexHull(p) ;
for(int i = 0 , n = qs.length ; i < n ; i++){
res += qs[i].dist(qs[(i + 1) % n]) ;
}
res += 2.0 * Math.PI * r ;
return res ;
}
public P[] convexHull(P[] ps){
int n = ps.length , k = 0 ;
if(n <= 0) return ps ;
Arrays.sort(ps , new Psort()) ;
P[] qs = new P[n+2] ;
for(int i = 0 ; i < n ; i++){
while(k > 1 && qs[k-1].sub(qs[k-2]).det(ps[i].sub(qs[k-1])) <= 0) k-- ;
qs[k++] = ps[i] ;
}
for(int i = n - 2 , t = k ; i >= 0 ; i--){
while(k > t && qs[k-1].sub(qs[k-2]).det(ps[i].sub(qs[k-1])) <= 0) k-- ;
qs[k++] = ps[i] ;
}
P[] res = new P[k-1] ;
System.arraycopy(qs , 0 , res , 0 , k-1) ;
return res ;
}
}
class P{
int x , y ;
public P(){
}
public P(int x , int y){
this.x = x ;
this.y = y ;
}
public P sub(P o){
return new P(x - o.x , y - o.y) ;
}
public double dot(P o){
return x * o.x + y * o.y ;
}
public double det(P o){
return x * o.y - y * o.x ;
}
public double dist(P o){
return Math.sqrt( Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) ) ;
}
}
class Psort implements Comparator<P>{
public int compare(P o1, P o2) {
if(o1.x != o2.x) return o1.x - o2.x ;
return o1.y - o2.y ;
}
}
class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
POJ1113凸包
最新推荐文章于 2021-02-16 18:11:24 发布
