【POJ 3614】 Sunscreen
【题目链接】
http://poj.org/problem?id=3614
【算法】
将MinSPF从大到小排序,每头牛找SPF值最大的防晒霜
【代码】
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std;
#define MAXC 2510 int i,j,c,l,ans; struct Infoa
{
int MinSPF,MaxSPF;
} a[MAXC];
struct Infob
{
int SPF,cover;
} b[MAXC]; inline bool cmp1(Infoa a,Infoa b)
{
return a.MinSPF > b.MinSPF;
}
inline bool cmp2(Infob a,Infob b)
{
return a.SPF > b.SPF;
} int main()
{ scanf("%d%d",&c,&l);
for (i = ; i <= c; i++) scanf("%d%d",&a[i].MinSPF,&a[i].MaxSPF);
for (i = ; i <= l; i++) scanf("%d%d",&b[i].SPF,&b[i].cover);
sort(a+,a+c+,cmp1);
sort(b+,b+l+,cmp2);
for (i = ; i <= c; i++)
{
for (j = ; j <= l; j++)
{
if (b[j].cover >= && b[j].SPF >= a[i].MinSPF && b[j].SPF <= a[i].MaxSPF)
{
b[j].cover--;
ans++;
break;
}
}
}
printf("%d\n",ans); return ; }
【POJ 3614】 Sunscreen的更多相关文章
- 【POJ - 3614】Sunscreen (优先队列)
Sunscreen Descriptions C (1 ≤ C ≤ 2500) 头奶牛在海滩边晒太阳,要避免在日光浴时产生难看的灼伤,每头奶牛必须用防晒霜覆盖它的皮肤.第 i 头奶牛有一个最小和最大 ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- 【链表】BZOJ 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 382 Solved: 111[Submit][S ...
- BZOJ2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 284 Solved: 82[Submit][St ...
- BZOJ2293: 【POJ Challenge】吉他英雄
2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 80 Solved: 59[Submit][Stat ...
- BZOJ2287: 【POJ Challenge】消失之物
2287: [POJ Challenge]消失之物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 254 Solved: 140[Submit][S ...
- BZOJ2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 126 Solved: 90[Submit][Sta ...
- BZOJ2296: 【POJ Challenge】随机种子
2296: [POJ Challenge]随机种子 Time Limit: 1 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 114 Solv ...
- BZOJ2292: 【POJ Challenge 】永远挑战
2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 513 Solved: 201[Submit][ ...
随机推荐
- 梦想CAD控件 2018.10.15更新
下载地址: http://www.mxdraw.com/ndetail_10105.html 1. 完善com接口的ToCurves函数,转换CAD文字,多行文字到曲线 2. 修改DrawImage接 ...
- form表单中只有一个input时,按回车键后表单自动提交(form表单的一个小坑)
form中只有一个input按回车键表单会自动提交 在一个form表单中,若只有一个input,按回车键表单会自动提交,但是当表单中存在多个input时,按回车键不会执行任何操作,这是form表单的一 ...
- Linux安装redis并且连接内网的redis
1.安装redis步骤 1.首先准备工作 [root@10-100-14-130 ~]# yum install gcc-c++ yum install wget 2.推荐进入到linux路径/ ...
- RC: blkio throttle 测试
本文将测试一下使用cgroup的blkio组来控制IO吞吐量 : 测试环境CentOS 7.x x64 创建一个继承组 [root@150 rg1]# cd /sys/fs/cgroup/blkio/ ...
- Mysql Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode
今天用mysql workbench在更新数据的时候,出现了下面错误:15:52:39 update wp_posts set post_content = replace(post_conte ...
- 关于datanode多磁盘存储策略
目的: 节点内各存储磁盘均衡 相关参数: dfs.datanode.fsdataset.volume.choosing.policy=org.apache.hadoop.hdfs.server.dat ...
- 【19】AngularJS 应用
AngularJS 应用 现在是时候创建一个真正的 AngularJS 单页 Web 应用(single page web application,SPA)了. AngularJS 应用实例 现在可以 ...
- 常州模拟赛d7t2 数组
题目背景 HJZ 有很多玩具.他最喜欢玩的玩具是一个可以变化的数组. 题目描述 HJZ 的数组初始时有 n 个元素.他可以把一个位置上的数加上或减去一个固定的 数 x. 一天 LJZ 和 HZY 来 ...
- zoj 3812 状压dp
转载:http://blog.csdn.net/qian99/article/details/39138329 题意:给出n个物品,每个物品有两种属性Wi,Ti,有q组查询,每组查询要求在n个物品中选 ...
- 【ZJOI2017 Round2练习&BZOJ4827】D1T3 gift(FFT)
题意: 思路:可以看出题目所要最小化的是这样一个形式: 拆出每一项之后发现会变化的项只有sigma a[i]*b[i+t]与c^2,c*(a[i]-b[i]) c可以在外层枚举,剩下的只有sigma ...