QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#760142 | #4629. Longest Increasing Subsequence | cjr2010 | RE | 0ms | 0kb | C++14 | 1.8kb | 2024-11-18 15:04:18 | 2024-11-18 15:04:19 |
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
7 7 41 53 58 75 78 81