http://acm.hdu.edu.cn/showproblem.php?pid=6638
题意:平面上有n个带权点,问用一个矩形围住的所有点权和最大是多少?
思路:把y坐标离散化,然后按x排序,枚举右边界,依次一列一列地加点,依次求最大子段和。
复杂度 O ( n ∗ n l o g ( n ) ) O(n*nlog(n)) O(n∗nlog(n))
#include<bits/stdc++.h>
using namespace std;
const int maxn=2010;
typedef long long ll;
int T,n;
struct Point{
int x,y,w;
bool operator < (Point z){
return x>z.x;
}
}p[maxn];
ll lmax[maxn*4],rmax[maxn*4],maxx[maxn*4],sumv[maxn*4];
void build()
{
memset(lmax,0,sizeof(lmax));
memset