题解:
首先我们给AA数组(糖果)和BB数组(药片)从小到大排个序。
lastilast_i 表示一个极大值 xx 使得 BxAiB_x 。
f(i,j)f(i,j) 表示枚举到第 AiA_i 时,有至少 jj 对匹配,使得 A???>B???A_{***}>B_{***}
然后枚举到 AiA_i 不代表也必须只能使用 BiB_i 以及其前的B数组元素。
f(i,j)=f(i?1,j)+...
分类:
其他好文 时间:
2015-04-03 09:34:16
阅读次数:
104
Unique Paths II - LeetCode
题目:
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is mar...
分类:
其他好文 时间:
2015-04-03 09:32:22
阅读次数:
105
1.POJ1837:Balance核心代码:基准点设dp[0][7500]=1;1 for (int k=1;k<=G;k++) 2 for (int j=0;j<N;j++)3 for (int i=1;i<=C;i++) 4 ...
分类:
编程语言 时间:
2015-04-02 20:53:00
阅读次数:
131
传送门:http://oj.cnuschool.org.cn/oj/home/addSolution.htm?problemID=571试题描述:我们把一个数称为有趣的,当且仅当:1. 它的数字只包含0, 1, 2, 3,且这四个数字都出现过至少一次。2. 所有的0都出现在所有的1之前,而所有的2都...
分类:
其他好文 时间:
2015-04-02 20:29:08
阅读次数:
151
problem:
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which
minimizes the sum of all numbers along its path.
Note: You can only move e...
分类:
其他好文 时间:
2015-04-02 16:27:56
阅读次数:
131
problem:
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 resp...
分类:
其他好文 时间:
2015-04-02 15:05:20
阅读次数:
127
http://soj.sysu.edu.cn/1001没想到sicily的1001就那么难,动态规划,好像也不是很难想,不过得考虑清楚各种情况,很坑,好像一共是3种,还有一个注意的是,输入是合法的,如果只输入30,那就没有一种解码方法了,这样的输入是不会出现的;还有,出现05这样的,也不能算是E.....
分类:
其他好文 时间:
2015-04-02 14:52:52
阅读次数:
202
题目:从1开始连续的整数构成一个字符串,问第n为位对应的字符是谁。
分析:动态规划,dp。统计每个数字对应的前面的子串的长度;
找到给定长度的对应的串的子串,然后取对应数字的n-len(子串)的字符即可。
说明:加油╮(╯▽╰)╭。
#include
#include
#include
#include
#include
#include
using ...
分类:
其他好文 时间:
2015-04-02 13:29:29
阅读次数:
134
问题:给定一个列表,第i个元素代表股票第i天的价值,只允许最多买入卖出两次,求最大收益思路:动态规划输入为列表p1p2...pm代码:Python
分类:
其他好文 时间:
2015-04-02 11:55:24
阅读次数:
125
问题:给定一个列表,第i个元素代表股票第i天的价值,最多只允许买入卖出k次,求最大收益思路:动态规划输入为列表p1p2...pm代码:Python
分类:
其他好文 时间:
2015-04-02 11:54:34
阅读次数:
205