CF1060D Social Circles】的更多相关文章

题意 题目链接 Sol 我是这样考虑的:从大到小考虑每个\(l, r\),最大的\(l\)应该和最大的\(r\)匹配(不然就亏了),其次次大的\(r\)应该和次大的\(l\)匹配 然后就过了.. /* */ #include<bits/stdc++.h> #define Pair pair<int, int> #define MP(x, y) make_pair(x, y) #define fi first #define se second #define int long lo…
思路: 贪心.既然每个人的左边是其他人的右边,每个人的右边是其他人的左边,那么使重叠的部分最多即可. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ], r[], n; int main() { while (cin >> n) { ; i < n; i++) { cin >> l[i] >> r[i]; } sort(l, l + n); sort(r,…
题意:有n个客人,第i个客人希望左边至少Li个空椅子,右边至少Ri个空椅子,每个客人都属于一个圈,问你最少需要准备的椅子数量 贪心做,每个人都可以去和另一个人牵手,组成一个新的人,那么我们让大的和大的牵手,小的和小的牵手,那么我们椅子就很有效的利用了,所以我们将L和R数组分别排序,每次取最大值加一 代码: #include<iostream> #include<vector> #include<cmath> #include<cstdio> #include…
题目传送门:http://codeforces.com/problemset/problem/1060/D 题意:有$N$个人,你要让他们坐成若干个圆环.他们每个人需要坐一把椅子,左手边至少要有$l_i$个空椅子,右手边至少要有$r_i$个空椅子,问最少需要多少个椅子.$N \leq 10^5 \,,\, l_i,r_i \leq 10^9$ 没有很好想,但也不难.贪心地考虑什么样的人会坐在相邻位置会使得答案最优,一定是一个人的左手与另一个人的右手相差较小时较好,因为这样子重复利用的椅子数量更多…
http://codeforces.com/contest/1060/problem/D 题意: n个客人,每个客人希望自己左边空li个座位,右边空ri个座位,可以形成任意个圆,问最少多少个座位. 思路: 1.问题可以看作,给每个客人gi的左边找一个合适的另一个客人gj.其之间的空座数为max(l(gi),r(gj)).这样匹配,自然会匹配为若干个圆. 2.将l和r排序,按大小顺利依次匹配,这样的总座位数最少. 证明:假设现在l和r都递增排好序.从匹配中任意找两对,例如(a, b),(c,d),…
10 signs you’re dating the wrong person10个迹象表明TA不是你的真心人       Do you have any exes who were so awful you can’t help wondering, “What the hell was I thinking?” Join the club. If you’d like to make sure you’re with Mr. or Ms. Right, watch out for these…
http://blog.csdn.net/pipisorry/article/details/49052255 海量数据挖掘Mining Massive Datasets(MMDs) -Jure Leskovec courses学习笔记之社交网络之社区检测:高级技巧-线性代数方法 Communities in Social Networks:  Intuitively, "communities" are sets of individuals in a network like Fa…
C - Maximum Subrectangle 因为是两个数组相乘的到的 矩阵所以  a(i ->j)*b(x->y) 的面积 就是   a(i ->j) 的和乘与b(x->y)的和 所以我们枚举 a 序列 从1-n的长度和  B序列同理 然后 枚举两个序列和相乘 找一个最大即可 #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define LL long long #defin…
Codeforces Round #513 游记 A - Phone Numbers 题目大意: 电话号码是8开头的\(1\)位数字.告诉你\(n(n\le100)\)个数字,每个数字至多使用一次.问最多能凑出多少个电话号码. 思路: 统计8出现的次数,如果有多余的8不能作为开头,那么就将其放到后面去 源代码: #include<cstdio> #include<cctype> #include<algorithm> inline int getint() { regi…
A. Phone Numbers 签. #include <bits/stdc++.h> using namespace std; #define N 110 char s[N]; ], n; int main() { while (scanf("%d", &n) != EOF) { scanf(); memset(cnt, , sizeof cnt); ; i <= n; ++i) ++cnt[s[i] - ']; ; ; i <= cnt[]; ++…