[USACO2007NOVG] Sunscreen
题目描述
To avoid unsightly burns while tanning, each of the$ C (1 ≤ C ≤ 2500) $cows must cover her hide with sunscreen when they're at the beach. Cow i has a minimum and maximum SPF rating (1 ≤ minSPFi ≤ 1,000; minSPFi ≤ maxSPFi ≤ 1,000) that will work. If the SPF rating is too low, the cow suffers sunburn; if the SPF rating is too high, the cow doesn't tan at all........
The cows have a picnic basket with \(L (1 ≤ L ≤ 2500)\) bottles of sunscreen lotion, each bottle i with an SPF rating SPFi (\(1 ≤ SPF_i ≤ 1,000\)). Lotion bottle i can cover coveri cows with lotion. A cow may lotion from only one bottle.
What is the maximum number of cows that can protect themselves while tanning given the available lotions?
输入格式
* Line 1: Two space-separated integers: C and L
* Lines 2..C+1: Line i describes cow i's lotion requires with two integers: minSPFi and maxSPFi
* Lines C+2..C+L+1: Line i+C+1 describes a sunscreen lotion bottle i with space-separated integers: SPFi and coveri
输出格式
A single line with an integer that is the maximum number of cows that can be protected while tanning
样例 #1
样例输入 #1
3 2
3 10
2 5
1 5
6 2
4 1
样例输出 #1
2
简化一下题意:给出很多个区间和点,一个区间和一个点匹配,要求点在区间内。
既然是匹配,可以考虑二分图匹配。但是太过麻烦了。
把所有的区间按照右端点从小到大虑选择最靠左的没被选的数。因为右区间没到的问题越到后面越不用考虑。那么左端点能选的就赶紧选了。
#include<bits/stdc++.h>
using namespace std;
const int N=2505;
struct node{
int l,r;
bool operator<(const node&n)const{
return r<n.r;
}
}d[N];
struct dian{
int x,y;
bool operator<(const dian&n)const{
return x<n.x;
}
}a[N];
int c,l,t,cnt;
int main()
{
scanf("%d%d",&c,&l);
for(int i=1;i<=c;i++)
scanf("%d%d",&d[i].l,&d[i].r);
for(int i=1;i<=l;i++)
scanf("%d%d",&a[i].x,&a[i].y);
sort(d+1,d+c+1);
sort(a+1,a+l+1);
for(int i=1;i<=c;i++)
for(int j=1;j<=l;j++)
if(a[j].y&&a[j].x>=d[i].l&&a[j].x<=d[i].r)
++cnt,a[j].y--,j=l;
printf("%d",cnt);
return 0;
}
···
[USACO2007NOVG] Sunscreen的更多相关文章
- POJ 3614 Sunscreen 贪心
题目链接: http://poj.org/problem?id=3614 Sunscreen Time Limit: 1000MSMemory Limit: 65536K 问题描述 to avoid ...
- poj 3614 Sunscreen
...
- Sunscreen(POJ 3614 优先队列)
Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5898 Accepted: 2068 Descrip ...
- POJ3614 Sunscreen 优先队列+贪心
Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her ...
- POJ--3614 Sunscreen(贪心)
题目 3614 Sunscreen 2500*2500直接排序暴力贪心 #include<iostream> #include<cstring> #include<alg ...
- Sunscreen POJ - 3614(贪心)
To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with s ...
- 洛谷 P2887 [USACO07NOV]防晒霜Sunscreen 解题报告
P2887 [USACO07NOV]防晒霜Sunscreen 题目描述 To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2 ...
- poj3614 Sunscreen【贪心】
Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11772 Accepted: 4143 Descri ...
- ACM题目————Sunscreen
Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her ...
- 优先队列:POJ No 3614 Sunscreen 贪心
Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6410 Accepted: 2239 Descrip ...
随机推荐
- Pytorch语法——torch.autograd.grad
The torch.autograd.grad function is a part of PyTorch's automatic differentiation package and is use ...
- 关于ChatGPT的一些闲扯淡(1)
这篇写的有点迟了,前者子ChatGPT正火的时候,懒病发作一直拖延.今天对ChatGPT做一个简单的讨论,也是把学习的心得和大家分享一下. 首先什么是GPT,英文全称是Generative Pretr ...
- 数据可视化【原创】vue复合数字形式展示
做数据可视化的时候,经常碰到需要很灵活的数字形式展示. 先上个效果图: 如图包括名称,数量,别名,单位,上升下降,环比等等的复合数据展示,并且需要支持样式灵活配置. 此组件包括2个模块,父容器组件bo ...
- 如何通过拼多多订单API接口获取订单详情
要获取拼多多订单详情,可以使用以下接口: 1. API名称:pdd.order.detail.get 接口说明:此接口用于查询某个订单的详情信息. API文档地址:前往注册 调用该接口需要提供以下参数 ...
- 让你的HpSocket Pull支持同步(应答式)操作
什么是HPSocket HP-Socket 是一套通用的高性能 TCP/UDP 通信框架,包含服务端组件.客户端组件和Agent组件,广泛适用于各种不同应用场景的 TCP/UDP 通信系统,提供 C/ ...
- 当你使用Taro时,你需要了解的一些事儿
2017 年 1 月 9 日凌晨,万众期待的微信小程序正式上线,前有跳一跳等爆圈小游戏的带动,后有特殊时期下各类健康码小程序的加持,小程序成为了国内技术圈独树一帜的存在.但随着小程序的迅猛发展,其实在 ...
- 循序渐进介绍基于CommunityToolkit.Mvvm 和HandyControl的WPF应用端开发(6) -- 窗口控件脏数据状态IsDirty的跟踪处理
在我们窗口新增.编辑状态下的时候,我们往往会根据是否修改过的痕迹-也就是脏数据状态进行跟踪,如果用户发生了数据修改,我们在用户退出窗口的时候,提供用户是否丢弃修改还是继续编辑,这样在一些重要录入时的时 ...
- 算法打卡|Day5 哈希表part01
哈希表 part01 今日任务 ● 哈希表理论基础 ● 242.有效的字母异位词 ● 349. 两个数组的交集 ● 202. 快乐数 ● 1. 两数之和 目录 哈希表 part01 链表理论基础 Pr ...
- Aveva Marine VBNET 编程系列-搭建开发框架
引用的Dll Aveva.ApplicationFramework.dll Aveva.ApplicationFramework.Presentation 菜单展示效果 创建Attribute,用于反 ...
- destoon关于archiver归档的性能优化
今天在处理一个项目时候发现archiver单个模块归档超过百万数据,打开速度就特慢,所以打开archiver下index.php文件进行分析,发现有句sql作怪 1 $result = $db-> ...