CS Round#50 D min-races
Min Races
Memory limit: 256 MB
In a racing championship there are N racing drivers. The drivers are divided in K classes.
After a race, a driver is declared a winner if all the drivers that finish in front of him are from better classes (with smaller indices than his own).
As the main organiser of the championship, you can choose for each race which drivers are allowed to participate. Find the minimum number of races needed such that every driver is a winner at least once.
Standard input
The first line contains 2 integers N and K.
Each of the next N lines contains 2 integers a_i and b_i. The first integer a_i represents the class of driver i, while b_i is his place in a race with all the N drivers.
Standard output
Print the answer on the first line.
Constraints and notes
- 1≤K≤N≤105
- There will be at least one driver from each class
- The values bb will be a permutation from 1 to N.
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000+10
struct per{int a,b;}p[MAXN];
int n,k,d[MAXN];
bool cmp(per x,per y){return x.b<y.b;}
int main(){
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++)scanf("%d%d",&p[i].a,&p[i].b);
sort(p+,p+n+,cmp);
d[]=p[].a;
int len=;
for(int i=;i<=n;i++){
if(d[len]>=p[i].a)d[++len]=p[i].a;
else{
int l=,r=len,mid,ans=-;
while(l<=r){
mid=(l+r)>>;
if(d[mid]<p[i].a){
ans=mid;
r=mid-;
}
else l=mid+;
}
d[ans]=p[i].a;
}
}
printf("%d\n",len);
return ;
}
CS Round#50 D min-races的更多相关文章
- DP BestCoder Round #50 (div.2) 1003 The mook jong
题目传送门 /* DP:这题赤裸裸的dp,dp[i][1/0]表示第i块板放木桩和不放木桩的方案数.状态转移方程: dp[i][1] = dp[i-3][1] + dp[i-3][0] + 1; dp ...
- 简单几何(水)BestCoder Round #50 (div.2) 1002 Run
题目传送门 /* 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 */ /***** ...
- CSA Round #50 (Div. 2 only) Min Swaps(模拟)
传送门 题意 给出一个排列,定义\(value为\sum_{i=1}^{n-1}abs(f[i+1]-f[i])\) \(swap(a[i],a[j])(i≠j)为一次交换\),询问最少的交换次数使得 ...
- Educational Codeforces Round 50
1036A - Function Height 20180907 \(ans=\left \lceil \frac{k}{n} \right \rceil\) #include<bits/ ...
- Round #427 A. Key races(Div.2)
time limit per test 1 second memory limit per test 256 megabytes input standard input output stand ...
- Cs Round#54 E Late Edges
题意:给定一个无向图,你从结点1开始走,每经过一条边需要1的时间,每条边都有一个开放时间,只有当目前所用的时间大于等于开放时间时,这条边才可以被经过.每一单位时间你都必须经过一条边,问最快什么时候可以 ...
- CS Round#53 C Histogram Partition
题意:给定一个数组A,以及一个初始值全为0的空数组B,每次可以对数组B的任意一个区间内的所有数+x,问至少几次操作能把B数组变成A数组 NOIP原题(积木大赛)升级版,话说CS怎么那么多跟NOIP原题 ...
- 【CS Round #36 (Div. 2 only) A】Bicycle Rental
[题目链接]:https://csacademy.com/contest/round-36/task/bicycle-rental/ [题意] 让你从n辆车中选一辆车; 每一辆车有3个属性 1.到达车 ...
- 【CS Round #39 (Div. 2 only) D】Seven-segment Display
[Link]:https://csacademy.com/contest/round-39/task/seven-segment-display/ [Description] 0..9各自有一个数字, ...
随机推荐
- ASP.NET Core 认证与授权[4]:JwtBearer认证
在现代Web应用程序中,通常会使用Web, WebApp, NativeApp等多种呈现方式,而后端也由以前的Razor渲染HTML,转变为Stateless的RESTFulAPI,因此,我们需要一种 ...
- [C#]使用ILMerge将源DLL合并到目标EXE(.NET4.6.2)
本文为原创文章,如转载,请在网页明显位置标明原文名称.作者及网址,谢谢! 本文主要是使用微软的ILMerge工具将源DLL合并到目标EXE,因此,需要下载以下工具: https://www.micro ...
- Problem S
Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. Bu ...
- AngularJS学习篇(十九)
AngularJS Bootstrap 可以在你的 AngularJS 应用中加入 Twitter Bootstrap,你可以在你的 <head>元素中添加如下代码: <link r ...
- HTML学习笔记 cs2D3D展示基础 第十四节 (原创) 参考使用表
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- oracle 归档模式开启后数据库宕机解决过程
首先按照网友说的shutdown immediately,结果hang了半个小时也么反应. 然后检查日志,全盘搜索.trc,发现 (D:\app\oracle\diag\rdbms\cms1u\cms ...
- 转:ef获取某个表中的部分字段值
我有个新闻表 id,title,body,createtime,author,click 使用ef4.1 仅仅读取 id,title,createtime 并显示在页面上. public static ...
- 利用C#来做ASP.NET的登陆页面
一.新建一个数据库 新建一个access数据user.mdb. 新建一个user表,添加:UserId(文本类型)及Password(文本类型)两个字段.二.新建一个default.aspx文件. 在 ...
- .net core 在视图中快速获取路由(Areas、Controller、Action)
我们在.net core中,经常碰到需要获取当前的Areas.Controller.Action,于是小编就扩展了Html,这样即可使用 Html.***来获取这些信息. 具体扩展类如下: publi ...
- Gmail,QMail,163邮箱的 IMAP/SMTP/POP3 地址
我们在客户端设置邮箱或者使用 PHPMailer 发送邮件的时候,我们都会去查找这些邮箱的 IMAP/SMTP/POP3 地址,这里就列出 Gmail, QMail, 163邮箱这三个常用邮箱的这些地 ...