hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0
Description
You are to find the maximum number of courses that a student can select.
Input
The first line of each test case contains an integer N. N is the number of courses (0<N<=300)
Then N lines follows. Each line contains two integers Ai and Bi (0<=A i<B i<=1000), meaning that the ith course is available during the time interval (Ai,Bi).
The input ends by N = 0.
Output
Sample Input
1 10
4 5
0
Sample Output
- #include <cstdio>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <cstring>
- using namespace std;
- const int maxn=550;
- struct node
- {
- int ai,bi;
- } task[maxn];
- int nn;
- bool mark[maxn];
- bool cmp(node A, node B)
- {
- if(A.bi==B.bi) return A.ai<B.ai;
- return A.bi<B.bi;
- }
- int solve(int ss)
- {
- int ans=0;
- memset(mark,0,sizeof(mark));
- for(int i=ss;i<=task[nn-1].bi;i+=5){
- for(int j=0;j<nn;j++){
- if(mark[j]) continue;
- if(i>=task[j].ai&&i<task[j].bi){
- ans++;
- mark[j]=1;
- break;
- }
- }
- }
- return ans;
- }
- int main()
- {
- int ans;
- while(scanf("%d",&nn),nn!=0){
- for(int i=0;i<nn;i++) scanf("%d%d",&task[i].ai,&task[i].bi);
- sort(task,task+nn,cmp);
- ans=0;
- for(int i=0;i<5;i++) ans=max(ans,solve(i));
- printf("%d\n",ans);
- }
- }
hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0的更多相关文章
- hdu 3695 10 福州 现场 F - Computer Virus on Planet Pandora 暴力 ac自动机 难度:1
F - Computer Virus on Planet Pandora Time Limit:2000MS Memory Limit:128000KB 64bit IO Format ...
- hdu 3687 10 杭州 现场 H - National Day Parade 水题 难度:0
H - National Day Parade Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & % ...
- hdu 3699 10 福州 现场 J - A hard Aoshu Problem 暴力 难度:0
Description Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. N ...
- hdu 3696 10 福州 现场 G - Farm Game DP+拓扑排序 or spfa+超级源 难度:0
Description “Farm Game” is one of the most popular games in online community. In the community each ...
- hdu 3694 10 福州 现场 E - Fermat Point in Quadrangle 费马点 计算几何 难度:1
In geometry the Fermat point of a triangle, also called Torricelli point, is a point such that the t ...
- hdu 3685 10 杭州 现场 F - Rotational Painting 重心 计算几何 难度:1
F - Rotational Painting Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & % ...
- hdu 3682 10 杭州 现场 C - To Be an Dream Architect 简单容斥 难度:1
C - To Be an Dream Architect Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d &a ...
- hdu 3682 10 杭州 现场 C To Be an Dream Architect 容斥 难度:0
C - To Be an Dream Architect Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d &a ...
- HDU 3697 Selecting courses(贪心)
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...
随机推荐
- 【Loadrunner】使用LR录制HTTPS协议的三种方法
使用LR录制HTTPS协议的三种方法 一.最简单的方法:浏览器配置打开浏览器,安装证书,配置完成后直接用http协议录制即可(配置完成的标识就是打开网页,不显示安全提示) 二.LR配置修改操作步骤如下 ...
- tools-eclipse-004-UML图安装
git:https://github.com/takezoe/amateras-modeler 下载:http://sourceforge.jp/projects/amateras/downloads ...
- OPENSSL编程 (secure shell, ssh)
很好的 OPENSSL编程 教程,名字就叫“OPENSSL编程” 它里面还有很多关于密码学的东西. http://www.pengshuo.me http://www.pengshuo.me/2014 ...
- hdu 5187 快速幂 + 快速乘 值得学习
就是以那个ai为分水岭,左边和右边都分别是单调增或单调减如图 就这四种情况,其中头两种总共就是两个序列,也就是从头到尾递增和从头到尾递减. 后两种方式就是把序列中德数分 ...
- cocos2dx 3.x 蒙板 遮罩 点击圆功能
//注册触摸 EventListenerTouchOneByOne *listener = EventListenerTouchOneByOne::create(); listener->onT ...
- [OpenCV入门教程之十二】OpenCV边缘检测:Canny算子,Sobel算子,Laplace算子,Scharr滤波器合辑
http://blog.csdn.net/poem_qianmo/article/details/25560901 本系列文章由@浅墨_毛星云 出品,转载请注明出处. 文章链接:http://blog ...
- HDU1059 二进制拆分优化多重背包
/*问你能不能将给出的资源平分成两半,那么我们就以一半为背包,运行多重背包模版 但是注意了,由于个数过大,直接运行会超时,所以要用二进制拆分每种的个数*/ #include<stdio.h> ...
- SQL学习笔记之SQL查询练习题1
(网络搜集) 0x00 表名和字段 –1.学生表 Student(s_id,s_name,s_birth,s_sex) –学生编号,学生姓名, 出生年月,学生性别 –2.课程表 Course(c_id ...
- 20145309李昊《网络对抗》MSF应用基础
实验内容 掌握metasploit的基本应用方式1.主动攻击——ms08_0672.针对浏览器的攻击——ms11_0503.针对客户端的攻击——Adobe4.成功应用一个辅助模块——scanner/d ...
- 20155201 2016-2017-2 《Java程序设计》第三周学习总结
20155201 2016-2017-2 <Java程序设计>第三周学习总结 教材学习内容总结 - 第四章要点: 4.1类与对象 类定义时使用class关键词,基本模式为 class na ...