码迷,mamicode.com
首页 >  
搜索关键字:kth largest    ( 1961个结果
[leetcode]Maximum Subarray
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-10 21:18:20    阅读次数:232
hdu1506(dp)
Largest Rectangle in a HistogramTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11219Accepted Subm...
分类:其他好文   时间:2014-08-10 18:24:20    阅读次数:225
每日一dp(1)——Largest Rectangle in a Histogram(poj 2559)使用单调队列优化
思路1. 当前为n的面积如何与n-1相联系,dp[i][j]=max(dp[i-1][k]) , 0<k<=j 描述:i为方块个数,j为高度 但是此题目的数据对于高度太变态,h,1000000000 ,n,100000 所以不可行(一般计算机为Ghz 相当于1S十几亿运算) 思路2. 此题目寻找的最大面积,对于一个方块来说则是以自己为中心左右两端比自己高 的方块累计和与自己面积的乘积,取最大值。状态转移则可看作已知前面n-1个左边比自己 高的的位置l[i],则如果该下标对应的数据比自己还高,继续往下找。利...
分类:其他好文   时间:2014-08-10 13:09:30    阅读次数:278
hdu 4006 The kth great number (优先队列+STB+最小堆)
The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 6637    Accepted Submission(s): 2671 Problem Description Xiao...
分类:其他好文   时间:2014-08-08 21:25:06    阅读次数:462
LeetCode——Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [?2,1,?3,4,?1,2,1,?5,4], the contiguous subarray [4,?1,2,1] ha...
分类:其他好文   时间:2014-08-05 22:37:50    阅读次数:188
UVa11324 - The Largest Clique(DAG+DP+SCC)
Problem B: The Largest Clique Given a directed graph G, consider the following transformation. First, create a new graph T(G) to have the same vertex set as G. Create a directed edge between two ve...
分类:其他好文   时间:2014-08-05 19:26:40    阅读次数:365
程序猿的自我修养清单
Data Structures    1. Integer       – find number of 1s       – next largest smaller       – smallest larger number       – determine if is palindrom       – itoa, atoi       – add 2 numbers w/...
分类:其他好文   时间:2014-08-05 15:50:40    阅读次数:408
uva 11324 The Largest Clique(图论-tarjan,动态规划)
uva 11324 The Largest Clique(图论-tarjan,动态规划) 题目大意: T组测试数据,给一张有向图G,求一个结点数最大的结点集,使得该结点中任意两个结点 u 和 v满足:要么 u 可以到达 v, 要么 v 可以到达 u(u 和 v 相互可达也可以)。 解题思路: ”同一个强连通分量中的点要么都选,要么不选。把强连通分量收缩点后得到SCC图,让每个SCC结点的权等于它的结点数,则题目转化为求SCC图上权最大的路径。由于SCC图是一个 DAG, 可以用动态规划求解。“...
分类:其他好文   时间:2014-08-05 14:17:19    阅读次数:244
HDU 1506 Largest Rectangle in a Histogram(DP)
可以发现 当第i-1个比第i个高的时候 比第i-1个高的所有也一定比第i个高 于是可以用到动态规划的思想 令left[i]表示包括i在内比i高的连续序列中最左边一个的编号 right[i]为最右边一个的编号 那么有 当h[left[i]-1]>=h[i]]时 left[i]=left[left[i]-1] 从前往后可以递推出left[i] 同理 当h[right[i]+1]>=h[i]]时 right[i]=right[right[i]+1] 从后往前可递推...
分类:其他好文   时间:2014-08-05 09:39:49    阅读次数:276
HDU 4006 The kth great number (基本算法-水题)
HDU 4006 The kth great number (基本算法-水题) 题目大意: 有m组操作,求第K大数。I为insert操作,即插入1个数,Q为询问,输出此时的第K大数。 解题思路: 一道水题让我智商捉鸡了,居然笨到想去用线段树去做。后来发现1个set搞定,就存K个大数,超过的把小的踢掉,输出第一个即可。...
分类:其他好文   时间:2014-08-03 23:19:36    阅读次数:287
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!