题目描述

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. 【opencv】传统目标检测:HOG+SVM实现行人检测

    传统目标分类器主要包括Viola Jones Detector.HOG Detector.DPM Detector,本文主要介绍HOG Detector与SVM分类器的组合实现行人检测. HOG(Hi ...

  2. 《Redis核心技术与实战》学习笔记总结目录

    1 Redis学习路径 去年我学习了极客时间的<Redis核心技术与实战>课程,在这门课程的学习中,我经常看到一位课代表的发言,他就是Kaito,他总结了一份Redis学习路径脑图(建议收 ...

  3. .NET Core基础到实战案例零碎学习笔记

    前言:前段时间根据 [老张的哲学] 大佬讲解的视频做的笔记,讲的很不错.此文主要记录JWT/DI依赖注入/AOP面向切面编程/DTO/解决跨域等相关知识,还包含一些.NET Core项目实战的一些案例 ...

  4. Anaconda平台下从0到1安装TensorFlow环境详细教程(Windows10+Python)

    1.安装Anaconda Anaconda下载链接:Free Download | Anaconda 下载完成之后,开始安装,修改安装路径至指定文件夹下,由于安装过程比较简单,此处略过: 2.Tens ...

  5. 商品详情api接口的应用方向有哪些?

    ​ 商品详情API接口的应用方向非常广泛,可以应用于以下领域: 电子商务平台:商品详情API接口可以提供商品的基本信息,如名称.描述.价格.图片等,帮助电子商务平台展示和推荐商品.此外,还可以提供商品 ...

  6. API数据接口获取商品详情数据该怎么操作

    随着电商行业的快速发展,获取商品详情数据是电商应用的重要功能之一.为了提高用户的购物体验,开发者可以利用API接口获取商品详情数据,方便用户了解商品的具体信息和特点.在本文中,我们将介绍如何使用API ...

  7. 微服务架构|go-zero 的自适应熔断器

    原文链接: go-zero 的自适应熔断器 上篇文章我们介绍了微服务的限流,详细分析了计数器限流和令牌桶限流算法,这篇文章来说说熔断. 熔断和限流还不太一样,限流是控制请求速率,只要还能承受,那么都会 ...

  8. SpringBoot打成jar运行后无法读取resources里的文件

    开发一个word替换功能时,因替换其中的内容功能需要 word 模版,就把 word_replace_tpl.docx 模版文件放到 resources 下 在开发环境中通过下面方法能读取word_r ...

  9. Z-Blog火车头免登录发布教程+插件3.2+支持最新Z-Blog1.7

    Z-Blog免登录采集评论,之前没有加入评论接口,今天把评论接口写好了,写一下简单的教程,(采集评论规则是一件很麻烦的事)有时候采集文章的时候也采集评论,今天教大家怎样用我的Z-Blog免登录采集插件 ...

  10. 聊聊基于Alink库的推荐系统

    概述 Alink提供了一系列与推荐相关的组件,从组件使用得角度来看,需要重点关注如下三个方面: 算法选择 推荐领域有很多算法,常用的有基于物品/用户的协同过滤.ALS.FM算法等.对于不同的数据场景, ...