经典单调队列 1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 const int N=1000010; 5 int maxq[N],minq[N],a[N],ans1[N],ans2[N],lmax,lmin,rmax, ...
http://acm.hdu.edu.cn/showproblem.php?pid=3415 初探单调队列,需要注意的是每次i维护的是i-1。 ...
分类:
其他好文 时间:
2016-09-30 07:35:21
阅读次数:
142
Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 55309 Accepted: 15911 Case Time Limit: 5000MS Description An array of size ...
分类:
其他好文 时间:
2016-09-28 22:11:34
阅读次数:
246
传送门:hdu 3401 Trade /************************************************************** Problem:hdu 3401 Trade User: youmi Language: C++ Result: Accepted T ...
分类:
其他好文 时间:
2016-09-25 19:06:50
阅读次数:
120
传送门 Description There is a sequence of integers. Your task is to find the longest subsequence that satisfies the following condition: the difference b ...
分类:
其他好文 时间:
2016-09-22 13:17:43
阅读次数:
235
题目链接:hdu_5884_Sort 题意: 有n个数,每个数有个值,现在你可以选择每次K个数合并,合并的消耗为这K个数的权值和,问在合并为只有1个数的时候,总消耗不超过T的情况下,最小的K是多少 题解: 首先要选满足条件的最小K,肯定会想到二分。 然后是如何来写这个check函数的问题 我们要贪心 ...
分类:
其他好文 时间:
2016-09-20 00:02:51
阅读次数:
306
传送门 蛤省省选果然水啊,我这种蒟蒻都能一遍A。 横向纵向维护两个单调队列,做两次求最大和最小的,总复杂度$O(NM)$ 码农题,考察代码实现能力 1 //BZOJ 1047 2 //by Cydiater 3 //2016.9.17 4 #include <iostream> 5 #include ...
分类:
其他好文 时间:
2016-09-17 23:20:34
阅读次数:
191
dp优化我总是不太熟练。这一次首先我写了O(n4)->O(n3)->O(n2)。一步步的优化过来。yyl好像用的是单调队列优化dp我看不懂他的代码。。。 O(n4) O(n3) O(n2) 1052 最大M子段和 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收 ...
分类:
其他好文 时间:
2016-09-14 19:03:25
阅读次数:
142
http://www.lydsy.com/JudgeOnline/problem.php?id=3672 http://uoj.ac/problem/7 链上的情况可以用斜率优化dp。树上用斜率优化dp时,单调队列的复杂度是均摊$O(n)$的,所以放到树上做“可持久化单调队列”复杂度是$O(n^2) ...
分类:
其他好文 时间:
2016-09-11 09:07:18
阅读次数:
151