#include <iostream>
#include <algorithm>
#include <algorithm>
#include <set>
using namespace std;
#define INF 0x3f3f3f3f
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[100005], b[100005];
int main(int argc, char** argv) {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
int num=0,flag=0;
for(int i=0;i<n;i++)
{
int l=0,r=0;
r=num;
// sort(b,b+num);//这里不用排序
while(r>l)
{
int mid=(l+r)/2;
if(b[mid]>a[i])
r=mid;
else l=mid+1;
}
b[r]=a[i];
if(r==num) num++;
}
cout<<num--<<endl;
return 0;
}
列车调度(贪心+二分)
最新推荐文章于 2024-07-22 16:30:20 发布