【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][ ...
随机推荐
- 观察者模式在Foundation框架通知中的应用
GitHub传送门 1.何为观察者模式? 观察者设计模式定义了对象间的一种一对多的依赖关系,以便一个对象的状态发生变化时,所有依赖于它的对象都得到通知并自动刷新. 举个简单的例子:你和你的舍友都订阅了 ...
- 配置redis三主三从
主从环境 centos7.6 redis4.0.1 主 从 192.168.181.139:6379 192.168.181.136:6379 192.168.181.136:6380 192.168 ...
- 习题练习(视觉slam14讲课后习题)
设有⼩萝⼘1⼀号和⼩萝⼘⼆号位于世界坐标系中. ⼩萝⼘⼀号的位姿为:q1 = [0.55, 0.3, 0.2, 0.2], t1 = [0.7, 1.1, 0.2]T(q 的第⼀项为实部).这⾥的 q ...
- cookie domain path 跨域
1.domain表示的是cookie所在的域,默认为请求的地址,如网址为www.jb51.net/test/test.aspx,那么domain默认为www.jb51.net.而跨域访问,如域A为t1 ...
- TestNG忽略测试
用@Test(enabled = false) 声明需要被忽略执行的测试方法 package com.janson; import org.testng.annotations.Test; publi ...
- Python使用Flask框架,结合Highchart,搭配数据功能模块处理csv数据
参考链接:https://www.highcharts.com.cn/docs/data-modules 1.javascript代码 var csv = document.getElementByI ...
- nginx代理标准配置
#nginx开启的进程数worker_processes 4; #4核CPU #定义全局错误日志定义类型,[debug|info|notice|warn|crit]error_log ...
- idea 编译级别的设置
File->Settings Project Structure
- ssh整合配置文件------web.xml配置
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://w ...
- I/O 模型及其设计模式
来源:伯乐在线 - 咸菜 链接:http://blog.jobbole.com/104638/ 前言 I/O在软件开发中的重要性无需多言,无论是在操作系统.网络协议.DBMS这种底层支撑软件还是在移动 ...