HDU 3697贪心
额...大意是你可以决定什么时候选课。然后呢。每五分钟只有一次机会选。每种课限制选课时间。问你能选到的课最多有多少、
感觉一点都不水。是自己太菜了吗?
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std; struct Node
{
int l, r;
} node[]; int cmp(Node a, Node b)
{
if (a.r != b.r) return a.r <b.r;
return a.l <= b.l;
} int main()
{
int n;
while(cin >> n)
{
if (n == ) break;
for (int i=; i<n; ++i)
{
cin >> node[i].l >> node[i].r;
}
sort(node, node+n, cmp);
int ans = ;
int vis[];
memset(vis, , sizeof(vis)); for (int i=; i<; ++i)
{
int st = i;
int tans = ;
memset(vis, , sizeof(vis));
//for (st=i; st<=node[n-1].r; st+=5)
while(st <= node[n-].r)
{
for (int j=; j<n; ++j)
{
if (vis[j]) continue;
if (node[j].l < st && node[j].r >= st)
{
//st += 5;
vis[j] = ;
tans += ;
break;
}
//st += 5;
}
st += ;
}
ans = max(ans, tans);
}
cout << ans << endl;
}
return ;
}
HDU 3697贪心的更多相关文章
- hdu 3697 贪心
#include<stdio.h> #include<stdlib.h> #include<string.h> #define inf 0x3fffffff #de ...
- HDU 3697 Selecting courses(贪心)
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...
- hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0
Description A new Semester is coming and students are troubling for selecting courses. Students ...
- HDU 3697 Selecting courses 选课(贪心)
题意: 一个学生要选课,给出一系列课程的可选时间(按分钟计),在同一时刻只能选一门课程(精确的),每隔5分钟才能选一次课,也就是说,从你第一次开始选课起,每过5分钟,要么选课,要么不选,不能隔6分钟再 ...
- HDU 3697 Selecting courses(贪心+暴力)(2010 Asia Fuzhou Regional Contest)
Description A new Semester is coming and students are troubling for selecting courses. Students ...
- hdu 3697 Selecting courses (暴力+贪心)
Selecting courses Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 62768/32768 K (Java/Others ...
- Hdu 5289-Assignment 贪心,ST表
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Assignment Time Limit: 4000/2000 MS (Java/Others) ...
- hdu 4803 贪心/思维题
http://acm.hdu.edu.cn/showproblem.php?pid=4803 话说C++还卡精度么? G++ AC C++ WA 我自己的贪心策略错了 -- 就是尽量下键,然后上 ...
- hdu 1735(贪心) 统计字数
戳我穿越:http://acm.hdu.edu.cn/showproblem.php?pid=1735 对于贪心,二分,枚举等基础一定要掌握的很牢,要一步一个脚印走踏实 这是道贪心的题目,要有贪心的意 ...
随机推荐
- Python字典猜解
摘要 目标 使用Python破解WordPress用户密码 使用Python破解zip压缩包密码 思路 通过表单提交项构建数据包,使用字典中的可选字符进行逐一排列组合暴力破解WordPress的用户密 ...
- 20165211 2017-2018-2 《Java程序设计》第2周学习总结
20165211 2017-2018-2 <Java程序设计>第2周学习总结 教材学习内容总结 本周,我学习了书本上二三两章的内容,以下是我整理的主要知识 第二章 基本数据类型与数 标识符 ...
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案(转载)
转载:http://www.th7.cn/Program/c/201303/127343.shtml 原因是Visual C++ 2012 使用了更加安全的 run-time library rout ...
- mybatis的注解开发之三种动态sql
脚本sql XML配置方式的动态SQL我就不讲了,有兴趣可以自己了解,下面是用<script>的方式把它照搬过来,用注解来实现.适用于xml配置转换到注解配置 @Select(" ...
- 移动端Css初始化
@charset "utf-8"; /* 禁用iPhone中Safari的字号自动调整 */ html { -webkit-text-size-adjust: %; -ms-tex ...
- 深度优先搜索初尝试-DFS-LakeCounting POJ No.2386
DFS入门的一道经典题目:LakeCounting 用栈或队列来实现: #include<cstdio> #include<stdlib.h> #include<iost ...
- 编译安装lamp (php)
用户账号及权限管理 用户账号:'user'@'host' user: 用户名 host: 此用户访问mysqld服务时允许通过哪些主机远程创建连接: host类型:IP.网络地址.主机名.通配符(%和 ...
- UVa 674 Coin Change(完全背包)
https://vjudge.net/problem/UVA-674 题意: 计算兑换零钱的方法共有几种. 思路: 完全背包基础题. #include<iostream> #include ...
- HDU 3466 Proud Merchants(0-1背包)
http://acm.hdu.edu.cn/showproblem.php?pid=3466 题意: 最近,iSea去了一个古老的国家.在这么长的时间里,它是世界上最富有和最强大的王国.结果,这个国家 ...
- EasyUI ---- draggable可拖动的用法
<link href="~/Scripts/easyui1.5/themes/default/easyui.css" rel="stylesheet" / ...