博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Task
阅读量:6689 次
发布时间:2019-06-25

本文共 2941 字,大约阅读时间需要 9 分钟。

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<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 2
100 3
100 2
100 1
 

 

Sample Output
1 50004
time:234ms
#include"iostream"#include"cstdio"#include"cstring"#include"cstdio"#include"map"#include"algorithm"using namespace std;const int ms=1e5+1;struct node{    int time;    int level;}machine[ms],task[ms];bool cmp(const node &a,const node &b){    if(a.time==b.time)            return a.level>b.level;    return a.time>b.time;}int main(){    int i,j,k,n,m;    long long ans,sum;    map
mp; while(scanf("%d%d",&n,&m)==2) { for(i=0;i
=task[i].time) { mp[machine[j].level]++; j++; } map
::iterator it=mp.lower_bound(task[i].level); if(it!=mp.end()) { ans++; sum+=(500*task[i].time+2*task[i].level); int t=it->first; mp[t]--; if(mp[t]==0) mp.erase(t); } } printf("%I64d %I64d\n",ans,sum); } return 0;}

超时代码:付下

/*	Name: 	Copyright: 	Author: 	Date: 06/08/14 14:38	Description: */#include"iostream"#include"cstdio"#include"cstring"#include"algorithm"using namespace std;const int ms=100001;struct node{	int time;	int level;}task[ms],machine[ms];bool cmp(const node &a,const node &b){	if(a.time==b.time)		return a.level
=task[i].time) { if(machine[j].level>=task[i].level&&vis[j]==0) { if(machine[j].level

  

转载于:https://www.cnblogs.com/767355675hutaishi/p/3894916.html

你可能感兴趣的文章
JQuery小技巧
查看>>
【Java】 JButton、JTextField、javax.swing.text.Document
查看>>
【BZOJ1030】[JSOI2007]文本生成器
查看>>
LG GPRO2 SudaMod 3.1 自编译版 20180524 更新
查看>>
Android系统移植与调试之------->增加一个双击物理按键打开和关闭闪光灯并将闪光灯状态同步到下拉菜单中...
查看>>
【测试工程师面试】记录自己的一次面试
查看>>
关于lettuce的一个基本操作的总结
查看>>
[转载]步进电机原理介绍与基于STM32的SPWM驱动步进电机,使用软件实现电机细分...
查看>>
css hack
查看>>
Python 递归
查看>>
第3章 敏捷项目管理概述
查看>>
C语言中函数strcpy ,strncpy ,strlcpy的用法
查看>>
让函数只执行一次的简化写法(非单列模式)
查看>>
Android深入浅出系列之Bluetooth—蓝牙操作(一)
查看>>
MapReduce入门
查看>>
软件测试作业03
查看>>
vs 代码格式化
查看>>
对话框Dialog总结
查看>>
权限管理系统
查看>>
病毒的基本知识
查看>>