zoukankan      html  css  js  c++  java
  • 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
    ",L);
        }
        return 0;
    }
  • 相关阅读:
    NumPy
    NumPy切片和索引
    NumPy来自数值范围的数组
    NumPy来自现有数据的数组
    NumPy数组创建例程
    NumPy数组属性
    hdu 1072 Nightmare
    hdu 1010
    nyoj zb的生日
    Catch That Cow
  • 原文地址:https://www.cnblogs.com/hua-dong/p/7605278.html
Copyright © 2011-2022 走看看