hihocoder #1309 : 任务分配

//http://www.spoj.com/MIT071/problems/ROMANRDS/

#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
//#include <map>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <bitset>
#include <algorithm>
#include <assert.h>
#include <set>
using namespace std;

void open(char *file)
{
    freopen(file,"r",stdin);
    int len=strlen(file);
    //.out;
    file[len]='t';
    file[len+1]=0;
    file[len-1]='u';
    file[len-2]='o';
    freopen(file,"w",stdout);
}
typedef long long lld;
bool dig(char x){return x>='0'&&x<='9';}
int dblcmp(double x)
{
    if(fabs(x)<1e-8)return 0;
    return x<0?-1:1;
}
double vabs(double x){return x<0?-x:x;}

const int MAX=100000+10;
const double EPS=1.0e-8;

struct INV
{
    int s,e;
    friend bool operator <(const INV &a,const INV &b)
    {
        if(a.s!=b.s)
        return a.s<b.s;

        return a.e<b.e;
    }
};
INV task[MAX];
int main()
{
    int n;
    int i;
    
    priority_queue<int>pq;
    cin>>n;
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&task[i].s,&task[i].e);
    }

    sort(task,task+n);

    for(i=0;i<n;i++)
    {
        if(!pq.empty())
        {
            int L=-pq.top();
            if(L<=task[i].s)
            {
                pq.pop();
                pq.push(-task[i].e);
            }
            else pq.push(-task[i].e);
        }
        else pq.push(-task[i].e);
    }

    cout<<pq.size()<<endl;

    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值