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各自有一个数字, ...
随机推荐
- win10 安装Node.js 报错:2503
解决方法: 使用管理员打开CMD
- A Very Simple Problem
A Very Simple Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- Azkaban安装部署
在root的用户下搭建的 • Azkaban安装部署(可参照:http://azkaban.github.io/azkaban/docs/latest/) 1):前提 安装JDK,安装Hadoop,H ...
- JavaScript中把Json字符串转化为对象
1.采用eval()函数 定义和用法 eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码. 语法 eval(string) 参数 描述 string 必需.要计算的字符串, ...
- header操作cookie
root@kl20080094:~# curl -I "http://www.xxx.com" HTTP/1.1 200 OK Server: nginx/0.8.53 Date: ...
- jQuery选择器(ID选择器)第一节
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- Jquery中attr 和 prop的区别和联系
昨天在选择借款方类型的时候总是会出现选择要点两次的现象,比如点击公司,第一次点击选择公司,没有选中,必须在次点击才可以选中,总感觉是有点延迟加载的意思,后来审查元素, 发现是redio元素,这样的话就 ...
- 【Kafka源码】处理请求
[TOC] 在KafkaServer中的入口在: apis = new KafkaApis(socketServer.requestChannel, replicaManager, groupCoor ...
- SQL Server 通过SQL脚本启动Broker并设置兼容性
SQL Server数据库中通过SQL启用Broker 并建立相关队列和服务 兼容代码使其可以在2000库中执行不报错 针对的是2008版本, 如果是其他版本可以改相关版本号和兼容性标记 /***** ...
- 集合>哈希表类Hashtable和SortedList排序列表类
集合>哈希表类Hashtable Hashtable一种键值对的集合 ,哈希表内部的排列是无序的,而且哈希表没有提供排序方法. 集合>哈希表类Hashtable>构造普通哈希表 代码 ...