上一页 1 ··· 21 22 23 24 25

2011年5月22日

HDU 1081 to the max

摘要: 将二维的动态规划问题转话为一维的动态规划问题#include <iostream>#include<string.h>using namespace std;int sequence[110][110];int N;int main(){ while(cin>>N) { int i,j,k; int data; int ans=-9999; for(i=1;i<=N;i++) { for(j=1;j<=N;j++) { cin>>data; sequence[i][j]=sequence[i][j-1]+data;//sequence 阅读全文

posted @ 2011-05-22 22:13 lonelycatcher 阅读(196) 评论(0) 推荐(0) 编辑

POJ 3264线段树的应用

摘要: #include<stdio.h>#include<string.h>struct node{ int max; int min; int l; int r;};node tree[200000];int h[50005];int max,min;int MAX(int a,int b){ if(a>b) return a; return b;}int MIN(int a,int b){ if(a>b) {return b;} return a;}void build(int l,int r,int root){ tree[root].l=l; tree[r 阅读全文

posted @ 2011-05-22 22:11 lonelycatcher 阅读(213) 评论(0) 推荐(0) 编辑

HDU 1754 I hate it 线段树的应用

摘要: #include<stdio.h>#define N_MAX 200010typedef struct { int left,right; int maxScore;}seg_tree;seg_tree trees[N_MAX*4 +1];int score[N_MAX+10];int get_max(int x,int y){ return x>y?x:y;}void build_tree(int root,int left,int right){ trees[root].left = left; trees[root].right = right; if(left == 阅读全文

posted @ 2011-05-22 22:01 lonelycatcher 阅读(169) 评论(0) 推荐(0) 编辑

上一页 1 ··· 21 22 23 24 25

导航