【NOIP2017提高A组模拟9.5】遥远的金字塔
Description
Input
Output
Sample Input
5 3
1 6
1 5
3 5
4 4
4 4
Sample Output
15
Data Constraint
Hint
题解
显然是DP
设f[i][j]表示选择了j个矩形,最后一个顶部在i层的最大覆盖面积
则转移有
可以想到斜率优化
code
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#define R register
#define max(a,b) (a>b?a:b)
using namespace std;
const int N=20100,M=105;
int n,m,d[M][N],h[M],t[M];
long long f[N<