求助,十个点全部RE
查看原帖
求助,十个点全部RE
68882
灵华楼主2021/7/27 18:42
#include <iostream>
#include <cstdio>
using namespace std ;

int n , m , k , axx , a[10055] , t[505][5055] ;

inline int lowbit ( int x )
{
	return x & -x ;
}

void add ( int x , int y , int z )
{
	int cy = y ;
	for ( ; x <= k + m ; x += lowbit ( x ) )
	{
		y = cy ;
		for ( ; y <= m + 1 ; y += lowbit ( y ) )
			t [ x ] [ y ] = max ( t [ x ] [ y ] , z ) ;
	}
}

int find ( int x , int y )
{
	int res = 0 , cy = y ;
	for ( ; x ; x -= lowbit ( x ) )
	{
		y = cy ;
		for ( ; y ; y -= lowbit ( y ) )
			res = max ( res , t [ x ] [ y ] ) ;
	}
	return res ;
}

int main ( )
{
	cin >> n >> m ;
	for ( int i = 1 ; i <= n ; ++ i )
	{
		cin >> a [ i ] ;
		k = max ( k , a [ i ] ) ;
	}
	for ( int i = 1 ; i <= n ; ++ i )
	{
		for ( int j = m ; j >= 0 ; -- j )
		{
			int x = find ( a [ i ] + j , j + 1 ) + 1 ;
			axx = max ( axx , x ) ;
			add ( a [ i ] + j , j + 1 , x ) ;
		}
	}
	cout << axx << endl ;
	return 0 ;
}

好奇怪啊,为啥十个点都RE了

好像讨论版里没有跟我一种情况的

数组开大一倍也是RE,我树状数组板子应该也没错呀

2021/7/27 18:42
加载中...