码迷,mamicode.com
首页 >  
搜索关键字:max sum    ( 43452个结果
hdu 4276(树形dp)
题意:带权树上有起点终点每个点上有宝藏,一个人只有T分钟要从起点到重点,问你最多能收集多少宝藏。思路:树形dp,首先判断能不能走到终点,然后把路径上的边权变为0时间减去所有边权。dp[v][j]表示从v出发回到v话费j分钟最多能收集到的宝藏。dp[v][j] = max(dp[v][j], dp[x...
分类:其他好文   时间:2014-05-10 01:47:33    阅读次数:324
C++ 数据类型及相关问题
1、有哪些数据类型?2、数据类型在不同的编译器会有不同的位宽,如何得知?使用如下命令:cout //该头文件必须加上。。。 cout::max()::min()::max()::max()::max()::min()<<endl;
分类:编程语言   时间:2014-05-10 01:39:39    阅读次数:419
P 1080 Human Gene Functions
大概作了一周,终于A了类似于求最长公共子序列,稍有变形当前序列 ch1 中字符为 a,序列 ch2 中字符为 b则有 3 种配对方式:1. a 与 b2. a 与 -3. - 与 b动态转移方程:dp[i][j] = max(dp[i - 1][j - 1] + g(ch1[i],ch2[j]) ,...
分类:其他好文   时间:2014-05-09 17:57:55    阅读次数:255
LeetCode: Triangle 题解
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
分类:其他好文   时间:2014-05-08 21:08:25    阅读次数:407
hdu 1159
题意:求最长子序列#include#includeusing namespace std;int max(int x,int y){ if(x>y) return x; return y;}int map[1001][1001];char s1[1001],s2[1001];int main(){ ...
分类:其他好文   时间:2014-05-07 20:07:29    阅读次数:202
shell脚本练习题(更新中...)
练习题(这里贴的是自己写的代码, 网上给的题目代码我会附加在最下面)1.编写shell脚本,计算1-100的和; 1 #!/bin/bash 2 #caculate the sum of numbers from 1 to 100 3 4 sum=0 5 for i in `seq 1 100`;....
分类:其他好文   时间:2014-05-07 19:34:54    阅读次数:305
[leetcode] Path sum路径之和
要求给定树,与路径和,判断是否存在从跟到叶子之和为给定值的路径。比如下图中,给定路径之和为22,存在路径,因此返回true;否则返回false. 5 / \ 4 8 / / \ 11...
分类:其他好文   时间:2014-05-07 10:15:46    阅读次数:270
Leetcode | Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:其他好文   时间:2014-05-07 09:36:09    阅读次数:300
杭电1231
1题目:给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 int main(){ int n, a[10001], left, beforeleft, right, i, max, sum; while...
分类:其他好文   时间:2014-05-06 13:18:27    阅读次数:366
Leetcode: Two Sum
这道题看似简单,其实很坑爹啊,动不动就是Time Limit Exceeded, 比如我下面这段TLE的代码,我感觉方法是对的,但是too naive,算法复杂度到了O(N^2),自然就TLE了而且有一些小语法错误需要注意:for(runner=current+1;;)不能用>;一定所有的case都...
分类:其他好文   时间:2014-05-06 11:31:09    阅读次数:405
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!