2011年5月4日

poj 1384

摘要: 完全背包。代码:#include<iostream>#include<fstream>using namespace std;int dp[10001];int e,f;int p[501],w[501];int n;void read(){// ifstream cin("in.txt"); int i,j,k; int cas; cin>>cas; while(cas--){ cin>>e>>f; cin>>n; for(i=1;i<=n;i++) cin>>p[i]>> 阅读全文

posted @ 2011-05-04 20:22 宇宙吾心 阅读(287) 评论(0) 推荐(0)

poj 1631

摘要: 最长不降子序列。代码:#include<iostream>#include<fstream>using namespace std;int a[40001],b[40001];int n;int find(int s,int value){ int i=0,k; while(i<=s) { k=(i+s)>>1; if(b[k]>value) s=k-1; else i=k+1; } return s;} void read(){ ifstream cin("in.txt"); int i,j,k; cin>>k; 阅读全文

posted @ 2011-05-04 19:37 宇宙吾心 阅读(368) 评论(0) 推荐(0)

poj 1661

摘要: 定义好状态.代码:#include<iostream>#include<fstream>using namespace std;struct e{ int left,right;};e dp[1010];struct a{ int x,y,h;};a map[1010];int cmp(const void *p,const void *q){ a *s=(a*)p; a *t=(a*)q; return t->h-s->h;}int n,maxx;int solve(int s,int f){ int x,y,h,i,j,k; if(f) x=map[s] 阅读全文

posted @ 2011-05-04 19:15 宇宙吾心 阅读(352) 评论(1) 推荐(0)

poj 1609

摘要: 题意:抽象的说,就是给出一列数对 ,求出其最长的递增序列的长度。用偏序定理,再LIS(nlogn).代码:#include<iostream>#include<fstream>using namespace std;int n;struct e{ int s,t;};e a[10001];int cmp(const void *a,const void *b){ e *s=(e*)a; e *t=(e*)b; if(s->s!=t->s) return s->s-t->s; else return s->t-t->t;} int b[ 阅读全文

posted @ 2011-05-04 18:06 宇宙吾心 阅读(469) 评论(0) 推荐(0)

导航