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 对于贪心,二分,枚举等基础一定要掌握的很牢,要一步一个脚印走踏实 这是道贪心的题目,要有贪心的意 ...
随机推荐
- Android实验一(在Android Studio中创建项目和模拟器)
北京电子科技学院(BESTI) 实 验 报 告 课程:移动平台开发 班级:1592 姓名:苏泽楠 学号:20159207 成绩: 指导教师 ...
- uva 1658 Admiral - 费用流
vjudge传送门[here] 题目大意:给一个有(3≤v≤1000)个点e(3≤e≤10000)条边的有向加权图,求1~v的两条不相交(除了起点和终点外没有公共点)的路径,使权值和最小. 正解是吧2 ...
- ubuntu下交叉编译ffmpeg
环境:ubuntu16.04 交叉编译器版本:4.8.3 依赖x264,lame x264: 1.wget ftp://ftp.videolan.org/pub/x264/snapshots/last ...
- SpringBoot中使用mybatis-generator自动生产
步骤: 1.在pom.xml中添加插件配置 <plugin> <groupId>org.mybatis.generator</groupId> <artifa ...
- js媒体查询设置根字号
!function(n){var e=n.document,t=e.documentElement,i=750,d=i/50,o="orientationchange"in n?& ...
- Unity3D学习笔记(十二):2D模式和异步资源加载
2D模式和3D模式区别:背景纯色,摄像机2D,没有深度轴 精灵图片设置 Normal map,法线贴图,更有立体感 Sprite (2D and UI),2D精灵贴图,有两种用途 1.当做UI贴图 2 ...
- MVC ---- EF的安装于卸载
先卸载EF:Uninstall-Package EntityFramework -Force 在安装EF5.0:Install-Package EntityFramework –Version 5.0 ...
- linux设置端口转发(一键设置)
linux设置端口转发 #下载rinetd程序并进入文件夹 wget http://www.boutell.com/rinetd/http/rinetd.tar.gz&&tar -xv ...
- 视图层view layer
视图层是Django处理请求的核心代码层,我们大多数Python代码都集中在这一层面. 它对外接收用户请求,对内调度模型层和模版层,统合数据库和前端,最后根据业务逻辑,将处理好的数据,与前端结合,返回 ...
- Java 常用对象-BigInteger类
2017-11-02 21:57:09 BigInteger类:不可变的任意精度的整数.所有操作中,都以二进制补码形式表示 BigInteger(如 Java 的基本整数类型).BigInteger ...