2013年1月10日
摘要: 小数据过了,大数据超时了,DP方法,先放这,mark一下#define SIZE 1000class Solution {public: int jump(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int f[SIZE]; for (int i = 0; i < SIZE; i++) f[i] = INT_MAX; f[0] = 0; ... 阅读全文
posted @ 2013-01-10 10:33 kkmm 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/remlostime/archive/2012/11/12/2765894.html用贪心策略,刚开始step = A[0],到下一步step--, 并且取step = max(step, A[1]),这样step一直是保持最大的能移动步数,局部最优也是全局最优。class Solution { public: bool canJump(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main... 阅读全文
posted @ 2013-01-10 09:22 kkmm 阅读(186) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <string>using namespace std;struct Interval { int start; int end; Interval() : start(0), end(0) {} Interval(int s, int e) : start(s), end(e) {}}; class Solution {public: inline int max(int a, int b) { return a > b ? a : b; } vo... 阅读全文
posted @ 2013-01-10 08:36 kkmm 阅读(190) 评论(0) 推荐(0) 编辑