zoukankan      html  css  js  c++  java
  • FatMouse's Speed

    本文纯属个人见解,是对前面学习的总结,如有描述不正确的地方还请高手指正~

        

    FatMouse's Speed

    
    
        每日一道理
    只有启程,才会到达理想和目的地,只有拼搏,才会获得辉煌的成功,只有播种,才会有收获。只有追求,才会品味堂堂正正的人。
    // File Name: hdu1160.cpp
    // Author: rudolf
    // Created Time: 2013年04月25日 木曜日 14时47分25秒
    
     #include<vector>
     #include<list>
     #include<map>
     #include<set>
     #include<deque>
     #include<stack>
     #include<bitset>
     #include<algorithm>
     #include<functional>
     #include<numeric>
     #include<utility>
     #include<sstream>
     #include<iostream>
     #include<iomanip>
     #include<cstdio>
     #include<cmath>
     #include<cstdlib>
     #include<cstring>
     #include<ctime>
     #include<string.h>
     using namespace std;
     const int maxn = 1005;
     struct node
     {
         int w,v,num;
     }mouse[ maxn ];
     int dp[ maxn ];
     int path[ maxn ];
     int cmp( node a1,node a2 )
     {
         if( a1.w!=a2.w ) 
    		 return a1.w<a2.w;
         else 
    		 return a1.v>a2.v;
     }
     int main()
     {
         int cnt=0;
         while( scanf("%d%d",&mouse[ cnt ].w,&mouse[ cnt ].v)!=EOF )
    	 {
             mouse[ cnt ].num=cnt+1;
             path[ cnt ]=-1;
             cnt++;
         }
         sort( mouse,mouse+cnt,cmp );
         int max_dp,max_num;
         max_dp=max_num=0;
         dp[ 0 ]=1;
         for( int i=1;i<cnt;i++ )
    	 {
             int my_max=0;
             for( int j=0;j<i;j++ )
    		 {
                 if( mouse[ j ].v>mouse[ i ].v && my_max<dp[ j ] && mouse[ j ].w!=mouse[ i ].w )
    			 {
                     my_max=dp[ j ];
                     path[ i ]=j;
                 }
             }
             dp[ i ]=my_max+1;
             if( max_dp<dp[ i ] )
    	{
                 max_dp=dp[ i ];
                 max_num=i;
             }
         }
         stack<int>s;
         s.push( mouse[max_num].num );
         while( path[max_num]!=-1 )
    	 {
             s.push(mouse[path[max_num]].num);
             max_num=path[max_num];
         }
         printf("%d\n",s.size());
         while( !s.empty() ) 
    	 {
             printf("%d\n",s.top() );
             s.pop();
         }
         return 0;
     }

        

    文章结束给大家分享下程序员的一些笑话语录: AdobeFlash拖垮Windows拖垮IE!又拖垮Linux拖垮Ubuntu拖垮FirxEox!还拖垮BSD拖垮MacOS拖垮Safri!简直无所不拖!AdobeFlash滚出网路世界!不要以为市占有率高就可以持续出烂货产品!以后替代品多得是!

  • 相关阅读:
    Understanding about Baire Category Theorem
    Isometric embedding of metric space
    Convergence theorems for measurable functions
    Mindmap for "Principles of boundary element methods"
    Various formulations of Maxwell equations
    Existence and uniqueness theorems for variational problems
    Kernels and image sets for an operator and its dual
    [loj6498]农民
    [luogu3781]切树游戏
    [atAGC051B]Three Coins
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3043424.html
Copyright © 2011-2022 走看看