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各自有一个数字, ...
随机推荐
- hadoop集群服务器配置注意事项
1.使用root账户,一劳记逸,远离权限问题. 2.关闭防火墙,命令:service iptables stop 想永久关闭,命令为:chkconfig iptables off 查看防火墙状态,命令 ...
- C++ stl 运用(深层)
1.multiset(set差不多) (1)erase删除,删除指针和键值是不同的. 键值的话是删除所有,指针的话是那个位置的值. (2)统计单个键值个数. (3)对于q.begin(),q.end( ...
- THINKPHP中几个缓存的问题
1.字段缓存. THINKPHP是默认开启字段缓存的.如果关闭了APPDEBUG(即在index.php中设置了这样一句话:define("APP_DEBUG","FAL ...
- ⑤bootstrap表格使用基础案例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- iOS 极光推送的集成以及一些集成后的狗血
1.首先进入极光文档下载激光推送的SDk---传送门http://docs.jiguang.cn/jpush/client/iOS/ios_sdk/ 将解压后的lib子文件夹(包含JPUSHSer ...
- 4. ZooKeeper 基本操作
ZooKeeper的数据模型及其API支持以下九个基本操作: 操作 描述 create 在ZooKeeper命名空间的指定路径中创建一个znode delete 从ZooKeeper命名空间的指定路径 ...
- JMeter基础教程3:脚本录制篇
对于一些JMeter初学者来说,录制脚本可能是最容易掌握的技能之一.虽然我不建议录制性能脚本(因为录制的脚本比较混乱,必须要通过二次处理才可正常使用),但有时做总比不做要好,是吧?下面我们详细介绍使用 ...
- 六:在线工具网站,让你PC上要装的软件少一半!
记住这几个在线工具网站,让你PC上要装的软件少一半! 一.uzer.me——丰富的云端应用聚合 这个云平台将我们常用的Office系列软件.Adobe家族的系列软件……乃至CAD制图都整合在了云端,随 ...
- fs-max、file-nr和nofile的关系
1. file-max /proc/sys/fs/file-max: 这个文件决定了系统级别所有进程可以打开的文件描述符的数量限制,如果内核中遇到VFS: file-max limit <num ...
- .net中LAMBDA表达式常用写法
这里主要是将数据库中的常用操作用LAMBDA表达式重新表示了下,用法不多,但相对较常用,等有时间了还会扩展,并将查询语句及LINQ到时也一并重新整理下: 1.select语句:books.Select ...