Beautiful People SGU - 199 ZOJ - 2319】的更多相关文章

最长上升子序列O(n log n):http://www.cnblogs.com/hehe54321/p/cf-340d.html 题目:https://cn.vjudge.net/problem/ZOJ-2319 https://cn.vjudge.net/problem/SGU-199 题意:给出一种数据,它有两个属性s和b.现在有它的两个实例x和y.定义如果 x.s<y.s&&x.b<y.b 或者 x.s>y.s&&x.b>y.b 那么x与y不…
[SGU 199] Beautiful People The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i-th member of this club (members being numbered by the time they entered the club) has streng…
The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i-th member of this club (members being numbered by the time they entered the club) has strength Si and beauty Bi. Since…
时间限制:0.25s 空间限制:4M 题意: 有n个人,每个人有两个能力值,只有一个人的两个能力都小于另一个的能力值,这两个人才能共存,求能同时共存的最大人数. Solution: 显然这是一个两个关键字的最长上升序列. 先按照第一种能力值为第一关键字从小到大,第二能力值为第二关键字从大到小排序(为什么?) 然后就是直接用O(nlogn)的DP就好了 (排序的方法是根据O(nlogn)DP算法中所用到的辅助数组的性质...如果对这个算法理解足够的话应该比较容易想到) code(要用C++提交)…
要邀请n个人参加party,每个人有力量值strength Si和魅力值 beauty Bi,如果存在两人S i ≤ S j and B i ≥ B j 或者  S i ≥ S j and B i ≤ B j 他们两个会产生冲突,问在不产生冲突的条件下,最多能邀请到几个人? [LIS]一开始将所有人按照Si升序排序,Si相同的按照Bi值降序排列,在这个基础上答案就是Bi的最长上升子序列的长度. 为什么Si相同时按照Bi值降序排列? 由求出的子序列时严格递增序列,如果对于相同的Si,Bi是递增,那…
LIS.先按S降序升序再按B降序排序(如果B不按降序排序的话就会覆盖掉正解),然后再对B用O(nlog(n))的LIS求解就可以了.用d数组标记每个元素在上升序列中的位置,然后根据d倒着找id就可以了. #include<algorithm> #include<iostream> #include<cstring> #include<fstream> #include<sstream> #include<cstdlib> #inclu…
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=20885 题意: 求二维最长严格递增子序列. 题解: O(n^2)的算法很好想,不过这里会t掉,只能O(nlogn) 于是用二分来维护: 先把所有的数按x递增排序,x相同的按y递减排序(这里之所以要按y递减排序是因为为了写代码方便,递减的话你后面基本就只要考虑y的大小,如果不递减,你还要考虑x的大小的,具体的可以自己思考一下) 排完序之后我们接下来就只考虑y的大小…
Beautiful People Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i-th member of this club (members b…
开始套题训练,第一套ASC题目,记住不放过每一题,多独立思考. Problem A ZOJ 2313 Chinese Girls' Amusement 循环节 题意:给定n,为圆环长度,求k <= n/2,从1出发,每次顺时针方向走k步,即1->k+1->2*k+1,直到遇到一个已经走过的点结束,要求最终把所有点访问一遍,最后回到1,使得k尽量大. 代码: Problem B ZOJ 2314 Reactor Cooling 无源汇上下界网络流 题意:经典题,有上下界无源无汇的可行流,对…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 题目描述: Mike is very lucky, as he has two beautiful numbers, 3 and 5. But he is so greedy that he wants infinite beautiful numbers. So he declares that any positive number which is…