最后一个点为什么TLE啊(恼)
查看原帖
最后一个点为什么TLE啊(恼)
751866
__DIOsama__楼主2023/6/22 12:48
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 100010
typedef long long ll;
ll a[N],x,l,dp[N],maxn;
ll g[N],cnt;
int main()
{
	std::ios::sync_with_stdio(false);
	while(std::cin>>x)
	{
		a[++l]=x;
	}
	for(int i=1;i<=l;i++)
	{
		int k=1;
		while(k<=cnt&&g[k]>=a[i])
		{
			k++;
		}
		if(k>cnt)
		{
			g[++cnt]=a[i];
		}
		else
		{
			g[k]=a[i];
		}
	}
	std::cout<<cnt<<std::endl;
	cnt=0;
	for(int i=1;i<=l;i++)
	{
		int k=1;
		while(k<=cnt&&g[k]<a[i])
		{
			k++;
		}
		if(k>cnt)
		{
			g[++cnt]=a[i];
		}
		else
		{
			g[k]=a[i];
		}
	}
	std::cout<<cnt<<std::endl;
}
2023/6/22 12:48
加载中...