zoj 1986 Bridging Signals

zoj 1986 Bridging Signals,第1张

zoj 1986 Bridging Signals
#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define P40010#define hpmax(a,b)((a)>(b)?(a):(b))int D[P], map[P];int p;int find( int len, int value ){int i, j, mid;i = 1; j = len;while ( i <= j ) {mid = (i+j)>>1;if ( D[mid] > value ) j = mid-1;else if ( D[mid] < value )i = mid+1;else return mid;}return i;}int main(){int t, i, j, k;scanf("%d", &t );while ( t -- ) {scanf("%d", &p);for ( i = 1; i <= p; ++ i ) {scanf("%d", &map[i] );}D[1] = map[1];j = 1;for ( i = 2; i <= p; ++ i ) {if ( map[i] > D[j] ) {D[++j] = map[i];}else {k = find( j, map[i] );D[k] = map[i];}}printf("%dn", j );}return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4912905.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存