题目描述

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的更多相关文章

  1. POJ 3614 Sunscreen 贪心

    题目链接: http://poj.org/problem?id=3614 Sunscreen Time Limit: 1000MSMemory Limit: 65536K 问题描述 to avoid ...

  2. poj 3614 Sunscreen

                                                                                                        ...

  3. Sunscreen(POJ 3614 优先队列)

    Sunscreen Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5898   Accepted: 2068 Descrip ...

  4. POJ3614 Sunscreen 优先队列+贪心

    Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her ...

  5. POJ--3614 Sunscreen(贪心)

    题目 3614 Sunscreen 2500*2500直接排序暴力贪心 #include<iostream> #include<cstring> #include<alg ...

  6. Sunscreen POJ - 3614(贪心)

    To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with s ...

  7. 洛谷 P2887 [USACO07NOV]防晒霜Sunscreen 解题报告

    P2887 [USACO07NOV]防晒霜Sunscreen 题目描述 To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2 ...

  8. poj3614 Sunscreen【贪心】

    Sunscreen Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11772   Accepted: 4143 Descri ...

  9. ACM题目————Sunscreen

    Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her ...

  10. 优先队列:POJ No 3614 Sunscreen 贪心

    Sunscreen Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6410   Accepted: 2239 Descrip ...

随机推荐

  1. 「AntV」x6 框选添加右键菜单

    今天在群里有个小伙伴提出了这么个问题:如何在框选完成后给框选的区域添加一个右键菜单的功能,我看到了这个问题后也是有点懵,心里想着怎么还有这个需求,直接快捷键删除不是更好吗,谁知这位小伙伴也是这么写的, ...

  2. 《Web安全基础》02. 信息收集

    @ 目录 1:CDN 绕过 1.1:判断是否有 CDN 服务 1.2:常见绕过方法 1.3:相关资源 2:网站架构 3:WAF 4:APP 及其他资产 5:资产监控 本系列侧重方法论,各工具只是实现目 ...

  3. Vue【原创】日历组件Calendar

    最近项目中封装了一个日历组件,用于节假日管理,支持输入默认选中的日期,选择管理日期. 效果图: calendar组件: 1 <template> 2 <div class=" ...

  4. webgl 刷底色的基本步骤

    1.在html中建立画布 <canvas id="canvas"><canvas> 2.在js中获取canvas画布 const canvas = docu ...

  5. MD5&MD5盐值加密到BCryptPasswordEncoder

    MD5&MD5盐值加密 Message Digest algorithm5,信息摘要算法: 压缩性:任意长度的数据,算出的MD5值长度都是固定的 容易计算:从原数据计算出MD5值很容易 抗修改 ...

  6. windows下的Sonarqube+Sonar-Scanner简单入门配置

    参考:https://blog.csdn.net/weixin_40496191/article/details/120250953 https://www.cnblogs.com/longpizi/ ...

  7. 关于oop的一点回忆

    昨天在一个程序员行业群里看到别人发了一条消息, 大意是:要做好封装啦,不要随便用public啦,不要随便改别人代码啦. 说的好像就是我,因为,我这辈子最后悔的一件事情之一就是手贱改动别人代码. 那大概 ...

  8. MySQL系列之读写分离架构——Atlas介绍、安装配置、Atlas功能测试、生产用户要求、Atlas基本管理、自动分表、关于读写分离建议

    文章目录 1. Atlas介绍 2.安装配置 3. Atlas功能测试 4. 生产用户要求 5. Atlas基本管理 6. 自动分表 7. 关于读写分离建议 1. Atlas介绍 Atlas是由 Qi ...

  9. Git——Git 常用命令

    文章目录 仓库 配置 增加/删除文件 代码提交 分支 标签 查看信息 远程同步 撤销 其他 仓库 # 在当前目录新建一个Git代码库 $ git init # 新建一个目录,将其初始化为Git代码库 ...

  10. Python并发编程——操作系统发展史、多道技术、进程理论、开启进程、join方法、进程间的数据隔离

    文章目录 必备知识回顾 今日内容详细 操作系统发展史 多道技术 必备知识点 多道技术图解 多道技术重点知识 进程理论 必备知识点 进程调度 进程运行的三状态图 两对重要概念 开启进程的两种方式 joi ...