HDU - 3697 Selecting courses
题目链接:https://vjudge.net/problem/HDU-3697
题目大意:选课,给出每门课可以的选课时间。自开始选课开始每过五分钟可以选一门课,开始
时间必须小于等于四,问最多可以选多少门课。
题目分析:贪心即可。
先按照结束时间进行排序,然后枚举不同开始选课时间可以选到的课程数目,
输出最大的即可。
(感觉这题题意好迷,怕是个题意题喲)
给出代码:
#include <cstdio> #include <iostream> #include <string> #include <set> #include <cmath> #include <algorithm> #include <cstring> #include <vector> #include <string> using namespace std; struct node { int beg; int ed; }; bool cmp(const node &a,const node & b) { if(a.ed!=b.ed) return a.ed<b.ed; else return a.beg<b.beg; } node nodes[+]; int n; int main() { while(cin>>n&&n) { ;i<n;i++) { scanf("%d%d",&nodes[i].beg,&nodes[i].ed); } sort(nodes,nodes+n,cmp); ]; ; ;s<;s++) { memset(vis,,sizeof(vis)); ; ].ed;i+=) { ;t<n;t++) { if(vis[t]) continue; else { if(i>=nodes[t].beg&&i<nodes[t].ed) { temp++; vis[t]=; break; } } } } maxn=max(maxn,temp); } cout<<maxn<<endl; } ; }
HDU - 3697 Selecting courses的更多相关文章
- HDU 3697 Selecting courses(贪心)
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...
- 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 3697 Selecting courses 选课(贪心)
题意: 一个学生要选课,给出一系列课程的可选时间(按分钟计),在同一时刻只能选一门课程(精确的),每隔5分钟才能选一次课,也就是说,从你第一次开始选课起,每过5分钟,要么选课,要么不选,不能隔6分钟再 ...
- Hdoj 3697 Selecting courses 【贪心】
Selecting courses Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 62768/32768 K (Java/Others ...
- hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0
Description A new Semester is coming and students are troubling for selecting courses. Students ...
- poj 2239 Selecting Courses (二分匹配)
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8316 Accepted: 3687 ...
- poj——2239 Selecting Courses
poj——2239 Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10656 A ...
- POJ-2239 Selecting Courses,三维邻接矩阵实现,钻数据空子。
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Description It is well known that ...
随机推荐
- 详解python之反射机制
一.前言 def f1(): print('f1') def f2(): print('f2') def f3(): print('f3') def f4(): print('f4') a = 1 t ...
- Linux 安装配置 Tomcat
1.下载 tomcat Linux 版本 oracle 官网下载地址:http://tomcat.apache.org/download-80.cgi 百度云盘链接:http://pan.baidu. ...
- MyBatis介绍
MyBatis 是支持普通 SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除了几乎所有的JDBC代码和参数的手工设置以及结果集的检索.MyBatis 使用简单的 XML或注解用于配 ...
- ssh无密码登录远程主机
方法:在客户端生成公/私钥对,将私钥文件保存在客户端,再将公钥文件上传到服务器端(远程主机) 1.在客户端生成公/私钥对 cb@cb251#ssh-keygen...cb@cb251#ls .ssh/ ...
- 如何用php实现文件上传与显示
首先,我们要创建一个前台页面用于操作选择文件等: <body> <div id="div1"></div> <form action=&q ...
- php面试问题
问题:请用最简单的语言告诉我PHP是什么? 回答:PHP全称:Hypertext Preprocessor,是一种用来开发动态网站的服务器脚本语言. 问题:什么是MVC? 回答:MVC由Model(模 ...
- ASP.NET Core 源码学习之 Options[2]:IOptions
在上一篇中,介绍了一下Options的注册,而使用时只需要注入IOption即可: public ValuesController(IOptions<MyOptions> options) ...
- ASP.NET Core配置Kestrel 网址Urls
ASP.NET Core中如何配置Kestrel Urls呢,大家可能都知道使用UseUrls() 方法来配置. 今天给介绍全面的ASP.NET Core 配置 Urls,使用多种方式配置Urls.让 ...
- 添加保存less报错
编辑器在添加保存less文件弹出一下错误: re-evaluation native module sources is not supported,if you are using the grac ...
- 【Android Developers Training】 77. 使用Wi-Fi P2P进行服务搜索
注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...