zoukankan      html  css  js  c++  java
  • HDU-2037-今年暑假不AC

    链接:https://vjudge.net/problem/HDU-2037

    题意:

    确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。 
    作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完整节目) 

    思路:

    贪心,先看最早结束的电视节目

    代码:

    #include <iostream>
    #include <memory.h>
    #include <string>
    #include <istream>
    #include <sstream>
    #include <vector>
    #include <stack>
    #include <algorithm>
    #include <map>
    #include <queue>
    #include <math.h>
    #include <cstdio>
    using namespace std;
    
    typedef long long LL;
    
    const int MAXN = 100 + 10;
    
    struct Node
    {
        int _l, _r;
        bool operator < (const Node & that) const 
        {
            return this->_r < that._r;
        }
    }node[MAXN];
    
    int main()
    {
        int n;
        while (cin >> n && n)
        {
            for (int i = 1;i <= n;i++)
            {
                cin >> node[i]._l >> node[i]._r;
            }
            sort(node + 1, node + 1 + n);
            int w = -1;
            int res = 0;
            for (int i = 1;i <= n;i++)
            {
                if (node[i]._l < w)
                    continue;
                res++;
                w = node[i]._r;
            }
            cout << res << endl;
        }
    
        return 0;
    }
    

      

  • 相关阅读:
    Antd下拉多选带勾选框
    POJ
    HDU 4281(01 背包+ 多旅行商问题)
    Codeforces Round #460 (Div. 2) D. Substring
    HDU
    POJ 2184 Cow Exhibition
    Codechef FRBSUM 解题报告
    UVA11982题解
    Suffix Array 后缀数组算法心得
    51nod1158 单调栈 个人的想法以及分析
  • 原文地址:https://www.cnblogs.com/YDDDD/p/10623834.html
Copyright © 2011-2022 走看看