hdu4864 Task 2014 Multi-University Training Contest 1
来源:互联网 发布:怎么挑选电子琴知乎 编辑:程序博客网 时间:2024/06/04 19:04
Task
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 259 Accepted Submission(s): 47
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.
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<xi<1440),yi(0=<yi<=100).xi is the maximum time the machine can work.yi is the level of the machine.
The following M lines each contains two integers xi(0<xi<1440),yi(0=<yi<=100).xi is the time we need to complete the task.yi is the level of the task.
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<xi<1440),yi(0=<yi<=100).xi is the maximum time the machine can work.yi is the level of the machine.
The following M lines each contains two integers xi(0<xi<1440),yi(0=<yi<=100).xi is the time we need to complete the task.yi is the level of the task.
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 2100 3100 2100 1
Sample Output
1 50004
Source
2014 Multi-University Training Contest 1
Recommend
We have carefully selected several similar problems for you: 4871 4870 4869 4868 4867
贪心的思想,任务和机器都按时间由大到小 时间相同等级由大到小排列,然后从任务开始 每次找出等级大于他的机器存进数组,在数组里取等级最小的用即可。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define inf 0x3f3f3f3ftypedef struct node{ int u,v;} nodepoi;nodepoi t1[111111],t2[111111];int c[111];int n,m,u,v;int cmp(node a,node b){ if(a.u==b.u)return a.v>b.v; return a.u>b.u;}int main(){ while(scanf("%d%d",&n,&m)!=EOF){ long long sum=0,num=0; memset(t1,0,sizeof(t1)); memset(t2,0,sizeof(t2)); memset(c,0,sizeof(c)); for(int i=0; i<n; i++){ scanf("%d%d",&u,&v); t1[i].u=u; t1[i].v=v; } for(int i=0; i<m; i++){ scanf("%d%d",&u,&v); t2[i].u=u; t2[i].v=v; } sort(t1,t1+n,cmp); sort(t2,t2+m,cmp); for(int i=0,j=0; i<m; i++){ while(j<n&&t1[j].u>=t2[i].u){ c[t1[j].v]++; j++; } for(int k=t2[i].v; k<=100; k++){ if(c[k]){ num++; c[k]--; sum+=500*t2[i].u+2*t2[i].v; break; } } } cout<<num<<' '<<sum<<endl; } return 0;}
0 0
- hdu4864 Task 2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1 — D. Task
- hdu 4864 Task---2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1 - 1004 / hdu 4864 Task
- hdu 4864 Task 2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1小记
- 2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1 题解
- 2014 Multi-University Training Contest 1
- 2014 Multi-University Training Contest 1--by FZU 解题报告
- 2014 Multi-University Training Contest 1/HDU4861_Couple doubi(数论/规律)
- 2014 Multi-University Training Contest 1 - A. Couple doubi
- hdu 4861 Couple doubi ---2014 Multi-University Training Contest 1
- 关于2014 Multi-University Training Contest 1的反思
- 2014 Multi-University Training Contest 1--by FZU 解题报告
- hdu4585 & BestCoder Round #1 项目管理(vector运用)
- 使用WireShark简单分析ICMP报文
- 网络拓扑距离的高效KNN查询
- 什么营销软件好用详情咨询
- Android游戏之仿 微信飞机大战
- hdu4864 Task 2014 Multi-University Training Contest 1
- Hibernate二级缓存
- OC 快速枚举总结
- MyEclipse10.6 myeclipse2013下添加jadClipse反编译插件 .
- hdoj 1013 Digital Roots
- how to solve "linux scp command not found"
- 孙鑫MFC第十四讲NET
- opencv 实现验证otsu
- vim 常用技巧总结