扫描线求每次的上下已有边长,同时区间合并记录边长的分布情况乘以高度差求出高度的变长
#include<cstring>
#include<string>
#include<iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<vector>
//#pragma comment(linker, "/STACK:1024000000,1024000000");
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 400005
vector<int>v;
int cnt;
struct edge
{
int l,r;
int h;
int tag;
friend bool operator < (edge a,edge b)
{
return a.h<b.h;
}
} line[maxn];
struct node
{
int l,r;
int add;
int sum;
int num;
int lt,rt;
} T[maxn];
void add_edge(int x,int y,int h,int d)
{
line[cnt].l=x;
line[cnt].r=y;
line[cnt].h=h;
line[cnt++].tag=d;
}
void init(int l,int r,int k)
{
T[k].l=l;
T[k].r=r;
T[k].add=0;
T[k].sum