zoukankan      html  css  js  c++  java
  • codeforces 479C Exams 解题报告

    题目链接:http://codeforces.com/problemset/problem/479/C

    题目意思:简单来说,就是有个人需要通过 n 门考试,每场考试他可以选择ai, bi 这其中一个时间来考,要求 n 门考试过后,他所选择的时间序列是一条非递减序列,输出最少时间。

          其实那个最少时间是骗人的,感觉没什么用。直接排序,然后每门课程选择尽可能少的时间来考,但这个时间需要满足 >= 前一门课程的时间。

          感觉这道题比 B 题还要简单,额。。。是错觉了么,不过它题目意思确实有点绕~~~~纸老虎题,把握关键的一些信息即可做出。

         

    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    
    #define  f  first
    #define  s  second
    const int maxn = 5000 + 5;
    pair<int, int> p[maxn];
    
    int main()
    {
        int n;
        while (scanf("%d", &n) != EOF)
        {
            for (int i = 0; i < n; i++)
            {
                scanf("%d", &p[i].f);
                scanf("%d", &p[i].s);
            }
            sort(p, p+n);
            int pre = min(p[0].f, p[0].s);    // 前一场考试的时间
            
            for (int i = 1; i < n; i++)
            {
                int tmp = min(p[i].f, p[i].s);
                pre = (tmp < pre ? max(p[i].f, p[i].s) : tmp);
            }
            printf("%d
    ", pre);
        }
        return 0;
    } 
  • 相关阅读:
    逻辑运算(二)
    Rust基础类型
    Rust简单demo
    逻辑基础(一)
    webpack配置typescript项目
    Go并发原理
    JS实现取任意类型的数组交集并集方法的思考
    JS 可逆加密的一种实现
    所有中文复姓
    将中文姓名转为拼音英文名的一种实现
  • 原文地址:https://www.cnblogs.com/windysai/p/4040339.html
Copyright © 2011-2022 走看看