/ Randle /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 3ms 328.0 KiB
#2 Accepted 3ms 332.0 KiB
#3 Accepted 2ms 324.0 KiB
#4 Accepted 1ms 324.0 KiB
#5 Accepted 2ms 336.0 KiB
#6 Accepted 2ms 320.0 KiB
#7 Accepted 2ms 324.0 KiB
#8 Accepted 12ms 588.0 KiB
#9 Accepted 16ms 972.0 KiB
#10 Accepted 18ms 968.0 KiB

代码

#include<cstdio>
#include<algorithm>
#include <iostream>
using namespace std;

int a[100005];
int d[100005];

int main()
{
	//freopen("sort.in","r",stdin);
	//freopen("sort.out","w",stdout);
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    if (n==0)  
    {
        printf("0");
        return 0;
    }
    d[1]=a[1];  
    int len=1;
    for (int i=2;i<=n;i++)
    {
        if (a[i]>=d[len]) d[++len]=a[i];  
        else  
        {
            int j=upper_bound(d+1,d+len+1,a[i])-d;  
            d[j]=a[i]; 
        }
    }
    printf("%d",len);    
    return 0;
}

信息

递交者
类型
递交
题目
序 T2
题目数据
下载
语言
C++
递交时间
2017-10-19 20:00:43
评测时间
2017-10-19 20:00:43
评测机
分数
100
总耗时
65ms
峰值内存
972.0 KiB