题目链接: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的更多相关文章

  1. HDU 3697 Selecting courses(贪心)

    题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...

  2. HDU 3697 Selecting courses(贪心+暴力)(2010 Asia Fuzhou Regional Contest)

    Description     A new Semester is coming and students are troubling for selecting courses. Students ...

  3. hdu 3697 Selecting courses (暴力+贪心)

    Selecting courses Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 62768/32768 K (Java/Others ...

  4. HDU 3697 Selecting courses 选课(贪心)

    题意: 一个学生要选课,给出一系列课程的可选时间(按分钟计),在同一时刻只能选一门课程(精确的),每隔5分钟才能选一次课,也就是说,从你第一次开始选课起,每过5分钟,要么选课,要么不选,不能隔6分钟再 ...

  5. Hdoj 3697 Selecting courses 【贪心】

    Selecting courses Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 62768/32768 K (Java/Others ...

  6. hdu 3697 10 福州 现场 H - Selecting courses 贪心 难度:0

    Description     A new Semester is coming and students are troubling for selecting courses. Students ...

  7. poj 2239 Selecting Courses (二分匹配)

    Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8316   Accepted: 3687 ...

  8. poj——2239 Selecting Courses

    poj——2239   Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10656   A ...

  9. POJ-2239 Selecting Courses,三维邻接矩阵实现,钻数据空子。

    Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K       Description It is well known that ...

随机推荐

  1. 每天一个JS 小demo之个人信息添加。主要知识点:DOM操作中的表格操作,节点操作

    以下是简易效果: <!DOCTYPE html><html lang="en"><head> <meta charset="UT ...

  2. 从String类型字符串的比较到StringBuffer和StringBuilder

    1. String类型 String类源码 为了从本质上理解String类型的特性所在,我们从String类型的源码看起,在源码中String类的注释中存在以下: /**Strings are con ...

  3. java 动态代理的实现

    http://www.cnblogs.com/jqyp/archive/2010/08/20/1805041.html

  4. 在React中使用Redux

    这是Webpack+React系列配置过程记录的第六篇.其他内容请参考: 第一篇:使用webpack.babel.react.antdesign配置单页面应用开发环境 第二篇:使用react-rout ...

  5. php中的命名空间

    a.php <?php namespace a\b; class Apple{ function get_info(){ echo 'aaa'.'<br/>'; } } ?> ...

  6. Java注解--实现动态数据源切换

    当一个项目中有多个数据源(也可以是主从库)的时候,我们可以利用注解在mapper接口上标注数据源,从而来实现多个数据源在运行时的动态切换. 实现原理 在Spring 2.0.1中引入了Abstract ...

  7. spring aop + xmemcached 配置service层缓存策略

    Memcached 作用与使用 基本介绍 1,对于缓存的存取方式,简言之,就是以键值对的形式将数据保存在内存中.在日常业务中涉及的操作无非就是增删改查.加入缓存机制后,查询的时候,对数据进行缓存,增删 ...

  8. URL和HTTP协议(无图片)

    URL...... 示例: http://localhost/phpwind/searcher.php?keyword=phpwind&type=thread 协议部分:一般是指URL中第一个 ...

  9. 【项目1-1】使用HTML5+CSS3绘制HTML5的logo

    作为一个WEB小萌新,自学了有一段时间,总是感觉停滞不前.最近反思中,想到前贤一句话:书读百遍其义自见.说到底,还是项目做的少,如果做多了,想必自然会得心应手. 利用HTML5+CSS3绘制HTML5 ...

  10. 我的学习之路_第二十七章_jQuery

    jQueryjs类库 把常用对象或者方法封装起来,让我们写代码效率更高 1.jQuery 2.extjs [jQuery入门] jQuery的引入: 通过script标签的src属性引入 入门: 获取 ...