题目链接: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. 快速上手 Kotlin 的 11 招

    本文转载自 Kotlin 公众号(KotlinX) 作者:bennyhuo 最近经常会收到一些 "用 Kotlin 怎么写" 的问题,作为有经验的程序员,我们已经掌握了一门或者多门 ...

  2. Android网络请求框架AsyncHttpClient实例详解(配合JSON解析调用接口)

    最近做项目要求使用到网络,想来想去选择了AsyncHttpClient框架开进行APP开发.在这里把我工作期间遇到的问题以及对AsyncHttpClient的使用经验做出相应总结,希望能对您的学习有所 ...

  3. 《学习OpenCV3》第7章第4题-SVD奇异值分解的验算

    原文题目: 中文翻译:   解题过程 d.使用OpenCV编写代码 , ,               , ,               ,);     Mat A = static_cast< ...

  4. Linux版微信

    一.到github上下载https://github.com/geeeeeeeeek/electronic-wechat/releases下载linux-x64.tar.gz,具体根据操作系统是32位 ...

  5. Ionic在Android上部署app步骤

    详情链接:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/ionic%E5%9C%A8android%E4%B8%8A%E9%83% ...

  6. 并发编程(一):从头到脚解读synchronized

    一.目录 1.多线程启动方式 2.synchronized的基本用法 3.深度解析synchronized 4.同步方法与非同步方法是否能同时调用? 5.同步锁是否可重入(可重入锁)? 6.异常是否会 ...

  7. .net core web api + Autofac + EFCore 个人实践

    1.背景 去年时候,写过一篇<Vue2.0 + Element-UI + WebAPI实践:简易个人记账系统>,采用Asp.net Web API + Element-UI.当时主要是为了 ...

  8. Linux常用操作命令(三)

    查看linux日志某几行 用逆序显示命令tail查看 命令格式:tail [  -r ] [  -n Number ] [ File ] [一]从第3000行开始,显示1000行.即显示3000~39 ...

  9. Vue和Bootstrap的整合之路

    我是一个刚刚接触前端开发的新手,所以有必要记录如何将Bootstrap和Vue进行整合. 如果你是老手,请直接绕道而过.作为一个新手,里面的步骤,过程或者专业术语未必正确,如果你发现哪里错误了,请发邮 ...

  10. css清除浮动float

    css清除浮动float 1.分析HTML代码 <div class="outer"> <div class="div1">1</ ...