将不小于m的数看作1,剩下的数看作0,那么只要区间内1的个数不小于k则可行,枚举左端点,右端点可以通过two-pointer求出。 时间复杂度O(n)O(n)。 #include <cstdio> #incl…
分类:B树
poj3320尺取法
这道意思是一本书有n页,每一页上有一个知识点标号a[i]可能重复,要求选择一个最小的区间使得能够覆盖所有知识点 分析:[l,r]区间推进,统计区间中能够覆盖的知识点数,对于每一个l,r都是满足可以覆盖所有知识点的最小r,…
poj2481树状数组
每个牛有一个区间[s,e],两个牛[s1,e1], [s2,e2],当s1<=s2并且e1>=e2并且e1-s1>e2-s2时,我们说牛1比牛2强,给N个牛的区间,对于每个牛,输出比这个牛强的牛的个数。…
hdu1075 map
http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意 翻译文本 Problem Description Ignatius is so lucky that he met a …
hdu2987 map
http://acm.hdu.edu.cn/showproblem.php?pid=2978 题意 给出一些串 用yes表示背过了该串,问最难背的子串(子串在yes中/子串在所有字串中的个数 最小)若子串在所有字串中的个…
hdu5969
http://acm.hdu.edu.cn/showproblem.php?pid=5969 要使或的和最大,要尽可能的让高位为1。将l和r两个数的二进制形式写出来,缺的补0,每一位都对齐,由于l<=r,所以在不相…
hdu1228 map
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include &l…
hdu1236结构体
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include…
hdu1862结构体中string成员之内存泄漏
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include…
手机键盘 模拟
题目描述 按照手机键盘输入字母的方式,计算所花费的时间 如:a,b,c都在“1”键上,输入a只需要按一次,输入c需要连续按三次。 如果连续两个字符不在同一个按键上,则可直接按,如:ad需要按两下,kz需要按6下 如果连续…
hdu1880魔咒词典
用map超内存,暴力写 MLE #include <iostream> #include <cstring> #include <cstdio> #include <map>…
hdu3783 ZOJ字符串处理
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> using namesp…