Dp[i][k] represents the minimum area that the I point is covered by a J rectangle
S[i][j] represents the area of the first point to the J Point
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 = k1; 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;
}