//堆排序//①维护堆 void max_heapify(int *ptr,int index,int len){ index = index + 1; int left = index ptr[index - 1]) largest = left; if(righ...
分类:
其他好文 时间:
2014-08-26 11:19:16
阅读次数:
186
1 int get_kth(int l,int r) 2 { 3 if (l==r) 4 return a[r]; 5 int i=l,j=r,mid=a[(l+r)>>1]; 6 while (imid)11 j--;12 ...
分类:
其他好文 时间:
2014-08-25 14:57:44
阅读次数:
189
记录动态规划dpl,dpr,分辨记录i左面的比i大的,右面比i大的,然后(dpr[i]-dpl[i]+1)*h[i]得出长度
动态转移方程while(temp>1 && h[temp-1]>=h[i]) temp=dpl[temp-1]
/*************************************************************************
> F...
分类:
其他好文 时间:
2014-08-25 01:11:53
阅读次数:
248
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist...
分类:
其他好文 时间:
2014-08-22 21:04:59
阅读次数:
168
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.思路:参见《浅谈用极大化思想解决最大子矩形问题》。这道题我不会,还...
分类:
其他好文 时间:
2014-08-21 22:45:04
阅读次数:
178
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?...
分类:
其他好文 时间:
2014-08-19 18:12:55
阅读次数:
279
非常难的问题,数组线性时间。属于我之前说的解法的借助辅助空间。给定两个柱子,他们之间的面积由什么确定呢?没错,他们之间的距离和他们之间最矮的那个柱子的高度。我们并不知道这个柱子在什么位置,所以仅仅能遍历,这个复杂度就上去了。那有没有一个方法避免找中间小柱子呢?先想什么情况下不用找。除非你知道枚举出两...
分类:
其他好文 时间:
2014-08-19 16:16:44
阅读次数:
176
Selection:selection is a trivial problem if the input numbers are sorted. If we use a sorting algorithm having O(nlgn) worst case running time, then t...
分类:
其他好文 时间:
2014-08-19 04:50:43
阅读次数:
200
A - Class Statistics Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 5682Description ///最开始 没有读懂 Largest....
分类:
其他好文 时间:
2014-08-18 18:13:42
阅读次数:
174
Description
Again Prime? No time.
Input: standard input
Output: standard output
Time Limit: 1 second
The problem statement is very easy. Given a number
n you have to determine the largest p...
分类:
其他好文 时间:
2014-08-18 14:34:52
阅读次数:
193