观察序列,要使信号不冲突,则必须要使序列递增,因此可以转化为最长递增子序列,DP,但是因为p ///最大可以取39999,数据量较大,所以选择O(nlogn)算法 #include<stdio.h> long map[40005]; int main() { int cas; scanf("%d",&cas); while(cas--) { long p,i,temp,top=0; map[0]=-1; scanf("%d",&p); for(i=1;i<=p;i++) { scanf("%d",&temp); if(temp>map[top]) map[++top]=temp; else { long low=1,high=top,middle; while(low<=high) { middle=(low+high)/2; if(temp>map[middle]) low=middle+1; else high=middle-1; } map[low]=temp; } } printf("--%d/n",top); } return 0; }