dp[i][k]表示i个点被j个矩形覆盖的最小面积
s[i][j]表示第i个点到第j个点的面积
dp[i][k]=dp[j][k-1]+s[j+1][i]
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 50 + 5 ;
int s [N] [N] ;
int dp [N] [5] ;
struct P {
int x , y ;
}a [N] ;
int cmp ( P l , P r ) {
if ( l.x == r.x ) return l.y < r.y ;
return l.x < r.x ;
}
int main (){
int n , K ;
scanf ( "%d%d" , &n , &K ) ;
for ( int i = 1 ; i <= n ; ++ i )
scanf ( "%d%d" , & a [i].y , & a [i].x ) ;
sort ( a + 1 , a + 1 + n , cmp );
for ( int i = 1 ; i <= n ; ++ i ){
int h = a [i].y , l = a [i].y ;
for ( int j = i ; j <= n ; ++ j ) {
h = max ( h , a [j].y ) ;
l = min ( l , a [j].y ) ;
s [i] [j] = (h-l)*(a[j].x-a[i].x);
}
}
memset ( dp , 127 , sizeof dp ) ;
for ( int i = 1 ; i <= n ; ++ i ){
dp [i] [1] = s [1] [i] ;
for ( int k = 2 ; k <= K ; ++ k )
for ( int j = k-1 ; j < i ; ++ j )
dp [i] [k] = min ( dp [i] [k] , dp [j] [k-1] + s [j+1] [i] );
}
printf ( "%d" , dp [n] [K] ) ;
return 0 ;
}