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.

InputThe 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.OutputFor 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

思路:本题和H(Alice and Bob)一样,可看作偏序,x的权重大于y,将machine的x大于等于task的y值入队,每次入队最小的大于task的y值的,这样就能保证后面的y可以更多的匹配,
而x在入队时已经得到保证,代码如下:
typedef long long LL;

const int maxm = ;

struct Node {
int x, y; bool operator<(const Node &a)const {
return x > a.x || (x == a.x && y > a.y);
}
} machine[maxm], task[maxm]; int n, t, tmp[]; int main() {
while(scanf("%d%d", &n, &t) == ) {
memset(tmp, , sizeof(tmp));
for (int i = ; i < n; ++i)
scanf("%d%d", &machine[i].x, &machine[i].y);
for(int i = ; i < t; ++i)
scanf("%d%d", &task[i].x, &task[i].y);
sort(machine, machine + n), sort(task, task + t);
int complete = ;
LL sum = ;
for(int i = , j = ; i < t; ++i) {
while(j < n && machine[j].x >= task[i].x) {
tmp[machine[j].y]++;
j++;
}
for (int k = task[i].y; k <= ; ++k) {
if(tmp[k]) {
++complete;
sum += task[i].x * * 1LL + * 1LL * task[i].y;
tmp[k]--;
break;
}
}
}
printf("%d %I64d\n", complete, sum);
}
return ;
}

补:

多者以上的贪心都要跟偏序挂钩

												

Day3-G - Task HDU4864的更多相关文章

  1. 牛客国庆集训派对Day3 G Stones

    Stones 思路: sg函数打表找规律 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #in ...

  2. Multi-tasking RTOS for microprocessors with limited memory by saving only a single return address per task during context switching

    A real-time operating system (RTOS) for use with minimal-memory controllers has a kernel for managin ...

  3. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  4. WSL(Windows Subsystem for Linux)--Pico Process Overview

    [转载] Windows Subsystem for Linux -- Pico Process Overview Overview This post discusses pico processe ...

  5. MTK6261 11C之Init Analysis【手记】

    初始化流程 Application_Initialize systemInitialization(); HWDInitialization(); USC_Start(); OSTD_Init(); ...

  6. windows下使用vscode编写运行以及调试C/C++

    未经允许,禁止转载,唯一出处:tangming博客园 最后更新于2019年4月4日: 多次更新,内容较多,篇幅较大,但如果是喜欢visual stdio code这款编辑器的话建议仔细阅读,有疑问的地 ...

  7. FuelPHP 系列(一) ------ Oil 命令

    之前用过 Laravel,框架自带的 artisan 命令,用得爽到爆.现在工作需要,要学习 FuelPHP,首先看到框架目录结构,有 coposer.json 框架可以用 composer 管理,一 ...

  8. Should I expose synchronous wrappers for asynchronous methods?

    In a previous post Should I expose asynchronous wrappers for synchronous methods?, I discussed " ...

  9. Should I expose asynchronous wrappers for synchronous methods?

    Lately I've received several questions along the lines of the following, which I typically summarize ...

随机推荐

  1. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(1)

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

  2. 2016-2017学年第三次测试赛 问题 F: 签到题

    问题 F: 签到题 时间限制: 1 Sec  内存限制: 128 MB提交: 80  解决: 28 提交统计讨论版 题目描述 在计算机网络考试中, 黑帅男神看到一个将IP网络分类的题, 精通C++的他 ...

  3. MySQL忘记密码如何重置

    一]进入服务器下,我用的是centos版本 vim /etc/my.cnf 1 vim[二]找到mysqld的部分然后在下面添加上一句代码,意思是跳过密码直接进入,然后保存退出 skip-grant- ...

  4. JavaScript高级特征之面向对象笔记

    Javascript面向对象 函数 * Arguments对象: * Arguments对象是数组对象 * Arguments对象的length属性可以获取参数的个数 * 利用Arguments对象模 ...

  5. Windows驱动开发-IRP超时处理

    IRP被送到底层驱动程序以后,由于硬件设备的问题,IRP不能得到及时处理,甚至有可能永远不会被处理,这时候需要对IRP超时情况进行处理,一旦在规定时间内,IRP没有被处理,操作系统就会进入到IRP的处 ...

  6. 使用TortoiseGit处理代码冲突

    使用TortoiseGit处理代码冲突  https://www.cnblogs.com/jason-beijing/p/5718190.html 场景一  user0 有新提交 user1 没有pu ...

  7. myBatis mapper接口方法重载问题

    在mybatis框架中,写dao层的mapper接口时,是不可以进行方法的重载的,下面是截图证明:   当mapper接口中有方法的重载时,会出现异常,   这是mapper接口中定义的两个方法,进行 ...

  8. Linux centosVMware zabbix主动模式和被动模式、添加监控主机、添加自定义模板、处理图形中的乱码、自动发现

    一.主动模式和被动模式 主动或者被动是相对客户端来讲的 被动模式,服务端会主动连接客户端获取监控项目数据,客户端被动地接受连接,并把监控信息传递给服务端 主动模式,客户端会主动把监控数据汇报给服务端, ...

  9. lib文件和dll文件

    一. 简介 1.1 C++两种库文件 lib包含了函数所在的dll文件和文件中函数位置的信息(入口),代码由运行时加载在进程空间中的dll提供,称为动态链接库dynamic link library. ...

  10. 页面自动执行js的3种方法

    1.最简单的调用方式,直接写到html的body标签里面:   <html> <body onload="load();"> </body> & ...