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. 《Web安全攻防 渗透测试实战指南》 学习笔记(一)

    Web安全攻防 渗透测试实战指南   学习笔记 (一) 第一章   信息收集     在信息收集中,最重要是收集服务器的配置信息和网站敏感信息(域名及子域名信息目标网站系统.CMS指纹.目标网站真实I ...

  2. vmware虚拟机linux添加硬盘后先分区再格式化操作方法

    先在虚拟机里填加硬盘,如图. 进入linux后台,df-l ,没有显示sdc盘,更切换的是,在fdisk中,却有sdc 看fdisk -l,确实有sdc. 说明sdc还没有分区,也没有格式化,也没有挂 ...

  3. logback.xml设置mogodb日志打印控制台

    <logger name="org.springframework.data.mongodb.core" level="DEBUG"/>

  4. tkinter的listbox、radiobutton和checkbutton学习(2)

    1.tkinter的listbox 1.1 代码 #第1步,导出模块 import tkinter as tk #定义窗口,及其标题.大小和位置 win = tk.Tk() win.title('Li ...

  5. cssdiv设置高宽百分比不起作用的问题

    div等元素设置宽高百分比都是基于包含他的块级对象的百分比高度,所以必须先设置包含它的块级对象高度与宽度,但是光设置body是不起作用的,必须同时设置html和body.   要使用百分比设置div宽 ...

  6. JavaWeb项目用浏览器打开网页出现Session Error提示的解决办法

    找到web.xml配置的原始配置的位置: <servlet> <servlet-name>dwr-invoker</servlet-name> <servle ...

  7. 解Bug之路-记一次调用外网服务概率性失败问题的排查

    前言 和外部联调一直是令人困扰的问题,尤其是一些基础环境配置导致的问题.笔者在一次偶然情况下解决了一个调用外网服务概率性失败的问题.在此将排查过程发出来,希望读者遇到此问题的时候,能够知道如何入手. ...

  8. MySQL之约束

    目录 约束(CONSTRAINT) mysql中的约束有哪些? 级联操作 产生的原因: 两种级联的定义方式 约束(CONSTRAINT) 什么是约束? ​ 是一种限制,对某一个东西的限制.例如宪法规定 ...

  9. 解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'

    1.启动 SpringBoot项目报错,使用的是Springboot.Spring.Mybatis连接Mysql数据库,启动SpringBoot项目报错,错误如下所示: _____ .__/\ .__ ...

  10. springMVC的 Converter转换器 和 Formatter

    Converter转换器 spring的Converter是可以将一种类型转换成另一种类型的一个对象, 自定义Converter需要实现Converter接口 日期转换器 import java.te ...