栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

Two TVs

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Two TVs

Problem - C - Codeforces

题目意思 你有2台电视,问你能不能看完视频

解题思路

可以定义两个变量 如果俩个变量在看电视但是下一个节目开始了,那就说明看不完全部节目

#include"bits/stdc++.h"
#define ll long long
#define pi pair
#define inf 0x3f3f3f3f
#define  _for(i,a,b) for(int i=a;i<=b;i++)
#define  for_(i,a,b) for(int i=a;i=b;i--)
#define fr_(i,a,b) for(int i=a;i>b;i--)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 2e5+5;
const ll mod = 1e9+7;
const double lp=1.000000011;
mapmp;
int n,x;
int a[N];
struct node{
    int l,r;
}arr[N];
bool cmp(node s1, node s2){
    if(s1.l != s2.l) return s1.l> n;
    _for(i,1,n) cin >> arr[i].l>> arr[i].r;
    sort(arr+1,arr+1+n,cmp);
    int q = -1 ,w = -1;
    _for(i,1,n){
        if(q < arr[i].l){
            q=arr[i].r;
        }else if(w < arr[i].l){
            w=arr[i].r;
        }else{
            cout << "NOn";
            return ;
        }
    }
    cout << "YESn";
}

int main()
{
    IOS;
    solve();
    return 0;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/739289.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号