cf754 754D - Fedor and coupons】的更多相关文章

2个多小时,弱智了..(连A都做不对,就不要做D了(迷)) #include<bits/stdc++.h> #define lowbit(x) x&(-x) #define LL long long #define N 100005 #define M 1000005 #define mod 2147483648LL #define inf 0x7ffffffff using namespace std; inline int ra() { ,f=; char ch=getchar()…
D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goo…
D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goo…
题意:给定n个优惠券,每张都有一定的优惠区间,然后要选k张,保证k张共同的优惠区间最大. 析:先把所有的优惠券按左端点排序,然后维护一个容量为k的优先队列,每次更新优先队列中的最小值,和当前的右端点, 之间的距离.优先队列只要存储右端点就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <…
还记得lyf说过k=2的方法,但是推广到k是其他的话有点麻烦.现在这里采取另外一种方法. 先将所有线段按照L进行排序,然后优先队列保存R的值,然后每次用最小的R值,和当前的L来维护答案即可.同时,如果Q的size()比k大,那么就弹出最小的R. 具体见代码: #include <stdio.h> #include <algorithm> #include <string.h> #include <set> #include <vector> #i…
D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goo…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goods in the supermarket hav…
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/转载请注明出处,侵权必究,保留最终解释权! Description All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The…
http://codeforces.com/contest/754/problem/D 题意: 给定几组区间,找k组区间,使得它们的公共交集最大. 思路: 在k组区间中,它们的公共交集=k组区间中右端点最小值-k组区间中左端点最大值.如果我们要区间大,那我们应该尽量让左端点小,右端点大. 先对区间按照左端点排序,然后用优先队列处理. 将区间按照左端点从小到大的顺序一一进队列,只需要进右端点即可,如果此时队列内已有k个数,则队首就是这k组区间的最小右端点,而因为左端点是从小到大的顺序进队列的,所以…
http://codeforces.com/contest/754/problem/D 给出n条线段,选出k条,使得他们的公共部分长度最大. 公共部分的长度,可以二分出来,为val.那么怎么判断有k条线段有共同的这个长度,而且选他们出来呢? 可以把右端点减去val - 1,那么以后就只需要k条线段至少有一个交点就可以了. 那么怎么确定这个交点呢? 我的做法是直接离散,然后暴力找出覆盖次数>=k的那个点. 复杂度好像有点高, log2e10 * nlogn #include <cstdio>…