Problem:
Problem J: Castle Wall

A new lord assumed the position by the death of the previous lord in a Far Eastern province.

The new greedy lord hates concave polygons, because he believes they need much wasted area to be drawn on
paper. He always wants to modify them to convex ones.

His castle is currently surrounded by a wall forming a concave polygon, when seen from the above. Of course
he hates it. He believes more area could be obtained with a wall of a convex polygon. Thus he has ordered his
vassals to have new walls built so they form a convex polygon.

Unfortunately, there is a limit in the budget. So it might be infeasible to have the new walls built completely. The
vassals has found out that only up to r meters of walls in total can be built within the budget. In addition, the new
walls must be built in such a way they connect the polygonal vertices of the present castle wall. It is impossible
to build both of intersecting walls.

After long persuasion of the vassals, the new lord has reluctantly accepted that the new walls might not be built
completely. However, the vassals still want to maximize the area enclosed with the present and new castle walls,
so they can satisfy the lord as much as possible.

Your job is to write a program to calculate, for a given integer r, the maximum possible area of the castle with
the new walls.

Input

The input file contains several test cases.

Each case begins with a line containing two positive integers n and r. n is the number of vertices of the concave
polygon that describes the present castle wall, satisfying 5 ≤ n ≤ 64. r is the maximum total length of new castle
walls feasible within the budget, satisfying 0 ≤ r ≤ 400.

The subsequent n lines are the x- and y-coordinates of the n vertices. The line segments (xi, yi) - (xi+1, yi+1)
(1 ≤ i ≤ n - 1) and (xn, yn) - (x1, y1) form the present castle wall of the concave polygon. Those coordinates are
given in meters and in the counterclockwise order of the vertices.

All coordinate values are integers between 0 and 100, inclusive. You can assume that the concave polygon is
simple, that is, the present castle wall never crosses or touches itself.

The last test case is followed by a line containing two zeros.

Output

For each test case in the input, print the case number (beginning with 1) and the maximum possible area enclosed
with the present and new castle walls. The area should be printed with exactly one fractional digit.

Sample Input

5 4
0 0
4 0
4 4
2 2
0 4
8 80
45 41
70 31
86 61
72 64
80 79
40 80
8 94
28 22
0 0

Output for the Sample Input

case 1: 16.0
case 2: 3375.0

Solution in C++ (judge verdict: Wrong Answer)

#include<iostream>
#include<cstdlib>
#include<cmath>
#include<complex>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

typedef complex<int> P;
const double eps= 1e-10;
const int N =100;
int cross(P a,P b){//ll?
  return a.real()*b.imag()-a.imag()*b.real();
}
//ê¼üÌf[^ðÈ­Í<0,È«½­È¢Í<=0É·éÆ¢¢B
int ccw(P a,P b){
  if ( cross(a,b) <0)return 1;
  else return -1;
}

bool cmp(const P&a,const P&b){
  if ( a.real() != b.real())return a.real()<b.real();
  else return a.imag() < b.imag();
}

void ConvexHull(int n,P *inp,P *out,int &p){
  sort(inp,inp+n,cmp);
  bool used[n];
  int num[n];
  fill(used,used+n,false);
  p=0;
  out[p++]=inp[0];out[p++]=inp[1];
  used[1]=true;
  num[0]=0;num[1]=1;
  for(int i=2;i<n;i++){
    while(p>=2){
      if ( ccw(out[p-1]-out[p-2],inp[i]-out[p-2]) ==1)break;
      else {
	used[num[p-1]]=false;
	p--;
      }
    }
    num[p]=i;
    used[i]=true;
    out[p++]=inp[i];
  }
  for(int i=n-2,t=p+1;i>=0;i--){
    if ( used[i] == true)continue;
    while(p>=t){//·ÅÉÊïÉÈÁ½_ðÁ³È¢æ¤É·éB
      if ( ccw(out[p-1]-out[p-2],inp[i]-out[p-2]) ==1)break;
      else p--;
    }
    out[p++]=inp[i];
  }
  return;
}

int polygon_area(const P *a,int n){
  int sum = 0;
  for(int i=0;i<n;i++){
    sum += (a[i%n].real()-a[(i+1)%n].real())*(a[i%n].imag()+a[(i+1)%n].imag());
  }
  if (sum < 0)sum=-sum;
  return sum;
}

double dist(P a){
  return sqrt((double)a.real()*a.real()+a.imag()*a.imag());
}

bool isp(P a,P b,P c){
  return dist(a-c)+dist(b-c) < dist(a-b)+eps;
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
  if (isp(a1,a2,b1))return true;
  if (isp(a1,a2,b2))return true;
  if (  ( cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)<eps ) && //-eps
	( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<eps))return true;
  else return false;
}

class Edge{
public:
  int num;
  double dist;
  int val;
};
vector<Edge>edge[N];

double dp[N][20001];

int solve(int n,P *in,double r){
  rep(i,n){
    REP(j,i+2,n+1){
      bool isok=true;
      for(int k=i+1;k<j;k++){
	if (ccw(in[j]-in[i],in[k]-in[i])==1){isok=false;break;}
      }
      if (!isok)continue;
      for(int k=i+1;k+1<j;k++){
	if (is_intersected_ls(in[i],in[j],in[k],in[k+1])){isok=false;break;}
      }
      if (!isok)continue;
      int tmp = polygon_area(in+i,j-i+1);
      if (i == 0  && j == n)break;
      edge[i].pb((Edge){j,dist(in[i]-in[j]),polygon_area(in+i,j-i+1)});
    }
  }
  
//    rep(i,n){
//      rep(j,edge[i].size())cout << i<<" " <<edge[i][j].num << " " <<
//        edge[i][j].dist<<" " << edge[i][j].val << endl;
//    }
  
  rep(i,n+1){
    rep(j,20001)dp[i][j]=1e20;
    dp[i][0]=0;
  }
  
  rep(i,n){
    rep(j,20001){
      if (i)dp[i][j]=min(dp[i][j],dp[i-1][j]);
      rep(k,edge[i].size()){
	int nexi=edge[i][k].num;
	int nexj=j+edge[i][k].val;
	double nev=dp[i][j]+edge[i][k].dist;
	if (nexj > 20000)continue;
	dp[nexi][nexj]=min(dp[nexi][nexj],nev);
      }
    }
  }

//   rep(i,n){
//     rep(j,20001){
//       if (dp[i][j] < 1e10)cout << i<<" " << j << " " << dp[i][j]<<endl;
//     }
//   }

  int ans = 0;
  for(int j=20000;j>0;j--){
    rep(i,n+1){
      if (dp[i][j] <= r+eps)return j;
    }
  }
  return 0;
}

main(){
  int n,r;
  int tc=1;
  P tmp[N],hoge[N],in[N],out[N];
  while(cin>>n>>r && n){
    int p=0;
    int ans=0;
    
    rep(i,n+1)edge[i].clear();

    rep(i,n){
      int x,y;
      cin>>x>>y;
      tmp[i]=P(x,y);
      hoge[i]=tmp[i];
    }
    ans = polygon_area(hoge,n);
    ConvexHull(n,hoge,out,p);
    
    int move=0;
    rep(i,n){
      if (out[0] == tmp[i]){
	move=i;
	break;
      }
    }
    rep(i,n){
      in[i]=tmp[(i+move)%n];
    }
    in[n]=in[0];

//     cout << "[";
//     rep(i,n){
//    cout << i <<" " << in[i]<<endl;
//       cout <<in[i] <<",";
    //}
//     cout << in[0] <<"]," << endl;

    //cout << ans << endl;
    ans+=solve(n,in,(double)r);
    printf("case %d: %.1lf\n",tc++,ans/2.);
      
  }
}