题目描述

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. 《SQL与数据库基础》04. SQL-DQL

    目录 DQL 基础查询 条件查询 分组聚合 聚合函数 分组查询 结果排序 分页限制 总结 本文以 MySQL 为例 DQL 语法结构: SELECT 字段列表 FROM 表名列表 WHERE 条件列表 ...

  2. 深入理解Linux内核——内存管理(2)

    提要:本系列文章主要参考MIT 6.828课程以及两本书籍<深入理解Linux内核> <深入Linux内核架构>对Linux内核内容进行总结. 内存管理的实现覆盖了多个领域: ...

  3. 代码检视的新姿势!在IDEA中得到沉浸式Code Review新体验

    大家好,好久不见,又见面了. 在消失的这段时间里,我做了件大事,见证了儿子的出生并陪伴其一天天的成长.停止更文的200多天里,还能得到小伙伴们持续的支持,让我备受鼓励.对一个技术人员而言,分享技术观点 ...

  4. 详细解释一下Spring是如何解决循环依赖问题的

    Spring是如何解决循环依赖问题的? 我们都知道,如果在代码中,将两个或多个Bean互相之间持有对方的引用就会发生循环依赖.循环的依赖将会导致注入死循环,这是Spring发生循环依赖的原因 循环依赖 ...

  5. Docker 镜像库国内加速的几种方法

    概述 在国内,拉取 Docker 镜像速度慢/时不时断线/无账号导致限流等,比较痛苦. 这里提供加速/优化的几种方法. 梳理一下,会碰到以下情况: 国内下载速度慢/时不时断线:是因为网络被限制了. 没 ...

  6. Solution Set -「ARC 124」

    「ARC 124A」LR Constraints Link. 我们可以把 \(1\sim n\) 个盒子里能放的球的编号集合全部求出来.然后就直接来. 注意题目已经给出了 \(k\) 个球的位置,所以 ...

  7. Centos7使用s3fs-fuse挂载minio对象存储实践

    Centos7使用s3fs-fuse挂载minio对象存储实践 事前准备 主机可以访问到对象存储API.例如minio默认的9000端口 主机安装好s3fs软件 已在minio上创建存储桶 安装s3f ...

  8. ES6-ES11最通俗易懂保姆级的笔记!人见人爱,花见花开。赶快动起你发财的小手收藏起来吧,满满的干货,你值得拥有!!

    1.  ES6 1.1  let变量声明以及声明特性 声明变量 let a; let b, c, e; let f = 100, g = "红石榴21", h = []; 特性: ...

  9. Oracle CloudWorld 2023:Safra Catz主题演讲——把客户的成功放在首要位置

    Safra Catz在Oracle CloudWorld 2023的开场演讲主题是"把客户的成功放在首要位置".她强调了客户的重要性,并说大家通过合作和技术可以实现几乎一切.她感谢 ...

  10. 2023 ICPC 网络赛 II

    开场顺着读了 AC 不会,B 是 KDT 优化建图板子,让 zsy 确认了一下并制止他现在做.把 D 转化转化成了经典问题·,当时以为是网络流,所以 zsy 签完 M 就上去写了,写一半发现假了,问了 ...