思路

先将 N 个 电视节目 排序 根据 结束时间 ,结束的早的 排在前面

然后 弄 K个标记 记录 结束时间

然后 遍历一下 每次 如果能插入的话 插入到 结束时间最小的那个 队列里面去然后 每次插入后 更新答案

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> using namespace std;
typedef long long LL; const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6; const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7; struct Node
{
int x, y;
}q[maxn]; bool comp(Node x, Node y)
{
return x.y < y.y;
} int main()
{
int n, k;
int ans = 0;
scanf("%d%d", &n, &k);
int x, y;
for (int i = 0; i < n; i++)
scanf("%d%d", &q[i].x, &q[i].y);
sort(q, q + n, comp);
vector <int> opt;
for (int i = 0; i < k; i++)
opt.push_back(0);
for (int i = 0; i < n; i++)
{
int vis = upper_bound(opt.begin(), opt.end(), q[i].x) - opt.begin();
if (vis)
{
opt.erase((vis - 1) + opt.begin());
opt.push_back(q[i].y);
ans++;
}
}
printf("%d\n", ans);
}

最新文章

  1. 51Nod 1278 相离的圆
  2. Python的下载与安装
  3. Web的结构组件
  4. Robot Framework--10 万能的evaluate
  5. Uva 524 Prime Ring
  6. 应用python编写简单新浪微博应用(一)
  7. How to index email and attachments in nsf files?
  8. ios中怎么获得当前版本号
  9. [转载]Linux服务器性能评估与优化
  10. 封装好的PHP分页类,简单好用--在开源看到的,取回来自己用
  11. 关于mysql binlog日志的格式说明
  12. ASP.NET core1.0 EF MYSQL搭建中碰到几个问题记录
  13. C# 通过KD树进行距离最近点的查找.
  14. springboot的lombok
  15. vue里的样式添加之类名改动 和style改动
  16. windows下缩短time_wait的时间
  17. activemq 无法消费! consumers are alive when the messages are stuck !
  18. rabbitmq简单实例
  19. Maven 标签
  20. Matlab用mpeaks函数求峰值点坐标

热门文章

  1. JS与原生OC/Swift相互调用总结
  2. 基于bootstrsp的jquery富文本编辑器的手冊说明
  3. python按行读取apk中版本号、包名等信息
  4. PJISP 修改 消息头Fromto字段
  5. C#中执行存储过程并在SQL server中调试
  6. logstash5安装并实现mariadb数据写入到elasticsearch
  7. win10 安装anaconda 无法使用pip 报错缺少SSL模块
  8. 基于 Token 的身份验证
  9. 高盛CEO致大学毕业生:要与有野心的人为伍
  10. android常用权限