HDU 1667 Nested Dolls
2012-02-28 20:50
246 查看
该题用到二分的方法:
#include<iostream> #include<algorithm> #include<cstdio> using namespace std; class Node { public: int h,w; }; bool cmp( Node a ,Node b ) { if( a.w == b.w ) return a.h > b.h; return a.w < b.w; } Node doll[20024]; int Doll( int n ) { int sum=0; int hash[20024]={0}; for( int i = 0; i< n ; i++ ) { int l = 0 ,r = sum; while( l < r ) { int k = ( l + r )>>1; if( hash[k]>=doll[i].h ) l = k + 1; else r = k; } hash[l] = doll[i].h; if( l == sum ) sum++; } return sum; } int main( ) { int n,m; while( scanf( "%d",&n )==1 ) { for( int i = 0; i< n ; i++ ) { scanf( "%d",&m ); for( int j = 0 ; j< m ; j++ ) scanf( "%d%d",&doll[j].w, &doll[j].h ); sort( doll , doll + m ,cmp ); printf( "%d\n",Doll( m ) ); } } return 0; }
相关文章推荐
- POJ 2286 HDU 1667 ZOJ 2396 The Rotation Game IDA*迭代加深搜索
- hdu 1677 Nested Dolls
- hdu 1667(IDA*)
- hdu 1667 IDA*
- HDU 1677 Nested Dolls
- HDU 1677 Nested Dolls
- hdu 1667 The Rotation Game(IDA*)
- hdu 1667 /poj 2286 The Rotation Game(经典迭代加深)
- hdu 1677 Nested Dolls
- HDU 1667
- HDU 1677 Nested Dolls
- hdu 1667 The Rotation Game(2004 Asia Regional Shanghai)
- HDU 1667 百练 1288 POJ 2286
- 【搜索进阶】HDU 1667 The Rotation Game
- HDU 1677 Nested Dolls
- HDU 1677 Nested Dolls (贪心)
- hdu 1667(IDA*)
- HDU 1677 Nested Dolls
- HDU 1677 Nested Dolls
- HDU 1277 Nested Dolls