标签:
Input
Output
Sample Input
Sample Output
#include"iostream" #include"cstring" #include"algorithm" typedef long long ll; using namespace std; const int maxn=180+10; int cass=0; struct node { int x,y,z; void get(int x2,int y2,int z2) { x=x2; y=y2; z=z2; } }a[maxn]; bool cmp(node a1,node a2) { int su1=a1.x*a1.y; int su2=a2.x*a2.y; return su1>su2; } int n; int k; ll h[maxn]; bool is(node a1,node a2) { if(a1.x<a2.x&&a1.y<a2.y) return true; return false; } void Init() { int x1,y1,z1; k=1; a[0].x=a[0].y=10000000; for(int i=0;i<n;i++) { cin>>x1>>y1>>z1; a[k++].get(x1,y1,z1); a[k++].get(y1,x1,z1); a[k++].get(z1,y1,x1); a[k++].get(x1,z1,y1); a[k++].get(y1,z1,x1); a[k++].get(z1,x1,y1); } sort(a+1,a+k+1,cmp); } void Work() { ll MAX=0; int i,j; memset(h,0,sizeof(h)); for(i=1;i<k;i++) { for(j=0;j<i;j++) { if(is(a[i],a[j])&&a[i].z+h[j]>h[i]) h[i]=a[i].z+h[j]; } MAX=max(h[i],MAX); } cout<<"Case "<<++cass<<": maximum height = "<<MAX<<endl; } int main() { while(cin>>n&&n) { Init(); Work(); } return 0; }
HDU 1069 monkey an banana DP LIS
标签:
原文地址:http://www.cnblogs.com/yilihua/p/4724656.html