hihocoder #1309 : 任务分配

来源:互联网 发布:传奇霸业轮回魔道数据 编辑:程序博客网 时间:2024/05/18 06:26
//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
原创粉丝点击