题目描述

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. 文心一言 VS 讯飞星火 VS chatgpt (78)-- 算法导论7.4 2题

    二.如果用go语言,证明:在最好情况下,快速排序的运行时间为 Ω(nlgn). 文心一言: 在最好情况下,快速排序的运行时间为Ω(nlgn)的证明如下: 快速排序是一种分治算法,它将一个数组分成两个子 ...

  2. [ABC128E] Roadwork

    2023-01-14 题目 题目传送门 翻译 翻译 难度&重要性(1~10):4 题目来源 AtCoder 题目算法 区间覆盖,线段树,双堆 解题思路 可以将问题转化为区间覆盖问题和单点查询问 ...

  3. Unity UGUI的Slider(滑动条)件组的介绍及使用

    Unity UGUI的Slider(滑动条)件组的介绍及使用 1. 什么是Slider组件? Slider(滑动条)是Unity UGUI中的一种常用UI组件用,于在用户界面中实现滑动选择的功能.通过 ...

  4. 【渗透测试】Vulnhub EMPIRE BREAKOUT

    渗透环境 攻击机:   IP: 192.168.149.128(Kali) 靶机:     IP:192.168.149.130 靶机下载地址:https://www.vulnhub.com/entr ...

  5. 开源 SD-Small 和 SD-Tiny 知识蒸馏代码与权重

    最近,人工智能社区在开发更大.更高性能的语言模型方面取得了显著的进展,例如 Falcon 40B.LLaMa-2 70B.Falcon 40B.MPT 30B; 以及在图像领域的模型,如 SD2.1 ...

  6. Vmware中的centos7突然连接不上网络了,网络适配器采用的是NAT模式,解决办法?

    进入Windows操作系统,然后右键点击我们的电脑,进入到管理界面 计算机-> 管理->服务和应用程序->服务,找到如下服务进程 VMware DHCP Service, VMwar ...

  7. 入门篇-其之一-第一个Java程序

    ️注意: 本文中包含实际操作,需要安装JDK.如果需要安装JDK,请按照这篇文章的步骤进行安装:点我查看JDK安装教程 小白可以多看几遍这篇文章,多敲几次代码 前面我们已经安装了JDK,接下来就是写一 ...

  8. 从 5s 到 0.5s!CompletableFuture 异步任务优化技巧,确实优雅!

    一个接口可能需要调用 N 个其他服务的接口,这在项目开发中还是挺常见的.举个例子:用户请求获取订单信息,可能需要调用用户信息.商品详情.物流信息.商品推荐等接口,最后再汇总数据统一返回. 如果是串行( ...

  9. 手写商用Java虚拟机HotSpot,疯狂磨砺技术中

    在当前Java行业激烈竞争的形式下,唯有掌握技术,心中才不能慌.在多年前,我就开始苦练底层技术,但是眼看百遍也不如手过一遍,所以我打算把虚拟机的精华实现部分用手敲出来,这个过程注定不会轻松,但是心态不 ...

  10. JNI编程之java层和native层的数组数据的交互

    一.前言 JNI中的数组类型分为基本类型数组和引用类型数组,他们的处理方式是不一样的.基本类型数组中的元素都是jni基本数据类型,可以直接访问:但是引用类型的数组中的元素是一个类的实例,不能直接访问, ...