Sunscreen
题目描述
The cows have a picnic basket with L (1 ≤ L ≤ 2500) bottles of sunscreen lotion, each bottle i with an SPF rating SPFi (1 ≤ SPFi ≤ 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?
输入
* 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
输出
样例输入
3 2
3 10
2 5
1 5
6 2
4 1
样例输出
2
分析:把奶牛按最小值排序,防晒霜按固定值排序,从最小的防晒霜枚举,满足条件即放入优先队列。再将最小值取出,更新ans。
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
int C,L;
pair<int,int> fuck[],you[];
priority_queue <int, vector<int>, greater<int> > q;
bool cmp(pair<int,int>a,pair<int,int>b){
return a.first<b.first;
}
void init() {
cin >> C >> L;
range(i, , C - )cin >> fuck[i].first >> fuck[i].second;
range(i, , L - )cin >> you[i].first >> you[i].second;
sort(fuck,fuck+C,cmp);
sort(you,you+L,cmp);
}
void solve(){
int j=,ans=;
range(i,,L-){
while(j<C&&fuck[j].first<=you[i].first){
q.push(fuck[j].second);
++j;
}
while(!q.empty()&&you[i].second){
int tmp=q.top();
q.pop();
if(tmp<you[i].first)continue;
++ans;
you[i].second--;
}
}
cout<<ans<<endl;
}
int main() {
init();
solve();
return ;
}
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 ...
随机推荐
- 【Validation】林轩田机器学习基石
这一节主要讲如何通过数据来合理的验证模型好不好. 首先,否定了Ein来选模型和Etest来选模型. (1)模型越复杂,Ein肯定越好:但是Eout就不一定了(见上一节的overfitting等) (2 ...
- VMware下Linux配置局域网和外网访问
我想尝试的是利用本机的ip+port来访问虚拟机上的web服务器,因为这样的话,我就能够将我的web服务器部署成为一个能让外网访问的服务器了,首先说下我的环境: 主机:系统win7,ip地址172.1 ...
- Rational Rose 使用技巧
1.浏览区 2.菜单项 其中Format选项中: 决定各项是否显示,也可以通过右击-option选择 3.常用快捷键: F1:任何时候都可以按F1获得相关帮助,把鼠标放在某条菜单上按F1可以获得这条菜 ...
- php + ajax实现 帖子点赞功能
知识: 一.首先页面需要加载jquery框架 二.ajax常用参数解释: ①.type:传输数据方式,get或者post ②.url:处理数据的PHP脚本 ③.data:传输的数据索引及值,值用js获 ...
- Arcgis桌面开发,Python引用GDAL库的方法
我用的是arcgis10.2,python版本是arcgis自动安装的Pythin2.7 1.下载gdal-111-1700-core.msi和对应的GDAL-1.11.1.win32-py2.7.m ...
- hdu 1007 Quoit Design (最近点对问题)
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- 性能优化-FSL(Force Synchronous Layout)强制同步布局
通过chrome的Perfermance工具记录程序性能,切换到帧模式,点开其中一帧,看详情,中间为紫色的区块代表Layout,右上角带有红色三角的为警告,是chrome告知的强制同步布局,即FSL. ...
- shell脚本——项目1
案例名称:系统初始化 背景:10台已装有linux系统的服务器 需求: 1.设置时区同步 2.禁用selinux 3.清空防火墙策略 4.历史命令显示操作时间 5.禁止root远程登录 6.禁止定时任 ...
- .ini配置CAN信息
#include <iostream> #include <windows.h>//这个头文件一定要添加,否则GetPrivateProfileString(...)函数无法使 ...
- 51Nod 1048 整数分解为2的幂 V2
题目链接 分析: $O(N)$和$O(NlogN)$的做法很简单就不写了...%了一发神奇的$O(log^3n*$高精度$)$的做法... 考虑我们只能用$2$的整次幂来划分$n$,所以我们从二进制的 ...