设为首页 加入收藏

TOP

HDU 4864(多校)1004 Task
2015-07-24 05:30:23 来源: 作者: 【 】 浏览:5
Tags:HDU 4864 多校 1004 Task
Problem Description Today the company has m tasks to complete. The ith task need xi minutes to complete. Meanwhile, this task has a difficulty level yi. The machine whose level below this task’s level yi cannot complete this task. If the company completes this task, they will get (500*xi+2*yi) dollars.
The company has n machines. Each machine has a maximum working time and a level. If the time for the task is more than the maximum working time of the machine, the machine can not complete this task. Each machine can only complete a task one day. Each task can only be completed by one machine.
The company hopes to maximize the number of the tasks which they can complete today. If there are multiple solutions, they hopes to make the money maximum.
Input The input contains several test cases.
The first line contains two integers N and M. N is the number of the machines.M is the number of tasks(1 < =N <= 100000,1<=M<=100000).
The following N lines each contains two integers xi(0 The following M lines each contains two integers xi(0 Output For each test case, output two integers, the maximum number of the tasks which the company can complete today and the money they will get.
Sample Input
1 2
100 3
100 2
100 1

Sample Output
1 50004

Source 2014 Multi-University Training Contest 1 我的渣代码就是过不了,看了大神 点击打开链接 的,开始觉得有BUG,后来想了想 这种方法真好,值得我去学习=-=
#include
    
     
#include
     
       #include
      
        #include
       
         using namespace std; const int maxn=1e5+10; int n,m; int h[maxn]; struct node{ int x,y; }e[maxn],f[maxn]; int cmp(node l1,node l2) { if(l1.x==l2.x) return l1.y>l2.y; return l1.x>l2.x; } int main() { while(~scanf("%d%d",&n,&m)) { memset(h,0,sizeof(h)); for(int i=0;i
        
         =f[i].x)//由于对e,f,都排了序所以找出大于f[i].x所有的e[j],将e[j].y储存起来; { h[e[j].y]++; j++; } for(int k=f[i].y;k<=100;k++)//从找到的e[j].y中选择最小的 { if(h[k])//判断是否存在 { h[k]--; num++; ans+=f[i].x*500+f[i].y*2; break; } } } printf("%d %I64d\n",num,ans); } return 0; } 
        
       
      
     
    


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇ns3添加模块之vanet-highway 下一篇poj1113Wall 求凸包周长 Graham扫..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: