51nod 1672【贪心+优先队列】

这种题越来越多了。

按照区间左端点排完序,用优先队列维护一下区间右端点

#include
using namespace std;
typedef long long LL;

const int N=1e5+10;
struct asd{
    int Left,Right;
}p[N];
bool cmp(asd x,asd y){
    if(x.Left == y.Left) return x.Right, greater >q;

int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&k,&m);
    sum[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        sum[i]=a[i]+sum[i-1];
    }
    while(!q.empty()) q.pop();
    for(int i=0;i


你可能感兴趣的:(贪心)