Live2d Test Env

HDU1257 最少拦截系统 (贪心+STL+二分)

第一次在博客园写博客,好紧张 。博客搬家居然很多代码成了乱码,欲哭无泪,妈咪。 

开学东西太多了吧,没时间写备注,有点时候只能贴个代码,以后有时间再加备注吧,只贴代码不是好习惯。

咦,贪心怎么写,我只会lowerbound(Q……Q)

 

 

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<memory.h>
#include<algorithm>
#include<cmath>
using namespace std;
int a[100000];
int main()
{
    int i,j,k,L=0,x,T,Minmax,pos;
    while(~scanf("%d",&T))
    {   
        L=0;
        for(i=1;i<=T;i++){
           scanf("%d",&x);
           pos=upper_bound(a+1,a+L+1,x)-a;
           if(pos>L)L++;
           a[pos]=x;
        }
        printf("%d\n",L);
    }
    return 0;
}

 

posted @ 2017-09-28 09:46  nimphy  阅读(280)  评论(0编辑  收藏  举报