摘要: 动态规划,最大上升子序列和。不同的是给的是长方体。 为了方便处理,笔者直接将每个长方体当做三个长方体处理,每个长方体的长大于等于宽。然后以长为主,宽为辅排序。 然后就和之前的那道FatMouse‘s speed一样了,当符合条件是,更新最大值。 下面是笔者第一次AC的代码:#include <iostream>#include <algorithm>using namespace std;struct State{ int length; int width; int height; int sum;} s[100];int cmp(const State& . 阅读全文
posted @ 2013-02-04 21:55 SF-_- 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 动态规划,最大上升子序列和。状态是每个位置的最大和,写出状态转移方程就好啦。和上一题FatMouse's Speed相似,而且简单一点。 下面是笔者的AC代码:#include <iostream>using namespace std;struct State{ int num; long long sum;} s[1001];int main(){ int i,j,n; long long max; while(cin>>n && n) { for(i=0;i<n;i++) { cin>>s[i].... 阅读全文
posted @ 2013-02-04 20:04 SF-_- 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 动态规划,最长上升子序列。看代码吧,可能更容易懂。#include <iostream>#include <algorithm>using namespace std;struct State{ int id; int weight; int speed; int pre; int num;};bool cmp(const State &a, const State &b){ if(a.weight!=b.weight) return a.weight<b.weight; else return a.speed>b.sp... 阅读全文
posted @ 2013-02-04 16:21 SF-_- 阅读(166) 评论(0) 推荐(0) 编辑