Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ...
分类:
其他好文 时间:
2015-07-20 21:27:30
阅读次数:
96
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
For example,
Given [0,1,0,2,1,0,1,3,2,1,2,1]...
分类:
移动开发 时间:
2015-07-20 19:45:52
阅读次数:
175
#include #include using namespace std;const int MAXN=10000000+5;char a[MAXN];int t;char b[3]={'w','y','h'};int main(){ scanf("%d",&t); getchar(); whil...
分类:
其他好文 时间:
2015-07-19 13:09:59
阅读次数:
152
这道题的思路很难想。 问你需要的最少实验次数,这是很难求解的,而且我们知道的条件只有三个,k、n、实验次数 。
所以我们不妨改变思路,转而求最高所能确定的楼层数 。 那么用d[i][j]表示用i个球,实验j次所能确定的最高楼层数 。
那么我们假设第j次实验是在k楼,有两种可能: 1、球破了,那么状态如何转移? 用了一个球,用了一次实验机会,所以最优情况一定是从d[i-1][j-1]转移过来的...
分类:
其他好文 时间:
2015-07-19 11:53:23
阅读次数:
110
Just a smile and the rain is goneCan hardly believe it (yeah)There’s an angel standing next to meReaching for my heartJust a smile and there’s no way ...
分类:
其他好文 时间:
2015-07-18 22:43:36
阅读次数:
122
n个部下,每个部下都要完成一个任务。每个任务需B时间交代,J时间执行。不能同时给两个部下同时交代任务。输出完成所有任务的最短时间。//Uva 11792#include #include #include #include #include #include #include #include #i...
分类:
其他好文 时间:
2015-07-17 18:00:45
阅读次数:
127
【算法题:求出高低不同的砖中能存多少水】「Trapping Rain Water」Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much ...
分类:
移动开发 时间:
2015-07-16 19:14:33
阅读次数:
120
这个问题是芭芭拉在采访中遇到的,不幸的是,的复杂性O(n2)该,太失望了,难怪没有通过面试。Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical l...
分类:
编程语言 时间:
2015-07-16 13:24:12
阅读次数:
157
一开始使用动态规划来解决这道问题:
将可行解分为两类,一类为包含8号线,一类为不包含8号线;
将8号线依次与0~7号线配对,求出包含8号线的那一类可行解的最大值;
如果已经知道不包含8号线的最大值,即前七条线中的最大值,一个较小的子问题的解;
比较上两步中的最大值,即得结果。#include
#include
using namespace std;cla...
分类:
其他好文 时间:
2015-07-16 09:54:35
阅读次数:
123
题意:
从右上角出发到左下角。搭一个直水管花费str,弯的ben。
问最小搭水管的花费。
做法
直接可以从地图右上角也就是( 1,n)点 出发,初始方向是向左的。注意此时还没有搭任何的水管。方向是因为从左边那个水厂流入所以向左。
然后就是在这个格子建水管,如果建直水管,他就继续向左,然后花费直水管的钱,到达(1,n-1)点,然后当前方向还是向左,然后在vis数组记录最小步数。
然后到达终点旁边的 那个格子的时候,此时,这个格子还没建造水管,如果此时向下,你可以花费转弯水管的钱让他到达终点,
如果此时向左...
分类:
其他好文 时间:
2015-07-15 22:47:26
阅读次数:
153