QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760142#4629. Longest Increasing Subsequencecjr2010RE 0ms0kbC++141.8kb2024-11-18 15:04:182024-11-18 15:04:19

Judging History

你现在查看的是最新测评结果

  • [2024-11-18 15:04:19]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-18 15:04:18]
  • 提交

answer

/*
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3f3f3f3f3f3f3f3fll
#define For(i,l,r) for(int i=(l),i##END=(r);i<=i##END;++i)
#define Rof(i,l,r) for(int i=(l),i##END=(r);i>=i##END;--i)
bool M_S;
const int N=100005;
const int M=20000007;
int len,tmp[M],lis[M];
int LIS(){
	int res=0;
	For(i,1,len){
		if(lis[res]<tmp[i]) lis[++res]=tmp[i];
		else{
			int pos=lower_bound(lis+1,lis+res+1,tmp[i])-lis;
			lis[pos]=tmp[i];
		}
	}
	return res;
}
int n,a[N];
namespace SUB6{
	int f[N][31];
	void MAIN(){
		cerr<<"SUB6\n";
		f[1][0]=1;
		For(i,2,n){
			int num=a[i]-a[i-1]-1;
			int cnt=0;while(num) cnt++,num/=2;
			// assert((1<<cnt)-1==num);
			// 2^cnt-1
			For(j,0,30) f[i][j]=f[i-1][j];
			For(j,1,cnt){
				For(k,0,j){
					f[i][j]=max(f[i][j],f[i-1][k]+(1<<(j-1)));
				}
			}
			f[i][0]++;
		}
		int ans=0;
		For(j,0,30) ans=max(ans,f[n][j]);
		cout<<ans<<'\n';
	}
}
vector<int> vec[N];
void insert(int dep,int l,int r){
	if(l>r) return ;
	int mid=(l+r)>>1;
	vec[dep].push_back(mid);
	insert(dep+1,l,mid-1);
	insert(dep+1,mid+1,r);
}
void MAIN(){
	cin>>n;
	For(i,1,n) cin>>a[i];
	bool FSUB6=1;
	For(i,1,n-1){
		int num=a[i+1]-a[i];
		FSUB6&=(__builtin_popcount(num)==1);
	}
	if(FSUB6){SUB6::MAIN();return ;}
	For(i,1,n) tmp[++len]=a[i];
	For(i,1,n-1) insert(1,a[i]+1,a[i+1]-1);
	For(i,1,114514){
		if(!(int)vec[i].size()) break;
		for(int j:vec[i]) tmp[++len]=j;
	}
	cout<<LIS()<<'\n';
}
bool M_T;
signed main(){
	freopen("lis.in","r",stdin);
	freopen("lis.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	double T_S=clock();MAIN();double T_T=clock();
	cerr<<"Time: "<<1.0*(T_T-T_S)/CLOCKS_PER_SEC<<"s"<<' ';
	cerr<<"Memory: "<<1.0*(&M_S-&M_T)/1048576<<"MiB"<<'\n';
	return 0;
}

詳細信息

Test #1:

score: 0
Dangerous Syscalls

input:

7
7 41 53 58 75 78 81

output:


result: