QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760143#4629. Longest Increasing Subsequencecjr2010RE 438ms207452kbC++141.7kb2024-11-18 15:04:432024-11-18 15:04:43

Judging History

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

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

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=20000005;
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(){
	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: 100
Accepted
time: 2ms
memory: 11488kb

input:

7
7 41 53 58 75 78 81

output:

22

result:

ok single line: '22'

Test #2:

score: 0
Accepted
time: 0ms
memory: 11168kb

input:

8
174 223 259 368 618 738 893 1810

output:

671

result:

ok single line: '671'

Test #3:

score: 0
Accepted
time: 2ms
memory: 14480kb

input:

62
145 189 225 631 638 643 880 1349 1399 1574 1655 1713 1714 2383 2496 2706 2787 2904 2985 3030 3050 3318 3461 3466 3500 3908 3945 4287 4379 4412 4579 4612 4630 4722 4781 4811 4858 4998 5098 5276 6181 6185 6412 6427 6464 6498 6548 6887 6917 7344 7532 7776 8347 8711 8928 8983 9269 9486 9517 9833 9855...

output:

2506

result:

ok single line: '2506'

Test #4:

score: 0
Accepted
time: 0ms
memory: 13568kb

input:

88
682 1542 2371 3402 5534 5587 7551 7837 8115 8420 8454 10265 12203 13354 14558 16443 16736 17324 17392 18981 22237 23902 24464 25309 26212 26253 27476 30809 32134 32566 32849 34823 35328 35390 35854 35927 35990 38817 38994 39401 39538 40551 41828 42329 42797 44736 49297 52129 52636 53241 53982 586...

output:

26799

result:

ok single line: '26799'

Test #5:

score: 0
Accepted
time: 3ms
memory: 13428kb

input:

572
24 394 464 487 741 811 1051 1168 1433 1513 1551 1639 1685 1698 1740 1907 2054 2070 2437 2604 2720 3013 3075 3173 3241 3628 3753 4123 4222 4368 4411 4588 4920 5720 5776 5819 5854 6425 6448 6669 6920 7009 7271 7401 7662 7663 8105 8257 8414 8439 8852 8983 9253 9433 9495 9617 9744 9793 9916 10472 10...

output:

25026

result:

ok single line: '25026'

Test #6:

score: 0
Accepted
time: 39ms
memory: 27796kb

input:

510
7613 7941 9698 12889 14330 14616 17027 22607 22788 26651 27092 28468 29067 31402 39819 41016 41243 52443 53161 53922 56126 66280 67121 72058 74960 76054 78045 78846 82131 82803 83705 86924 89644 90248 96173 96254 96449 104403 104576 107259 109898 110394 115976 117077 120346 123220 124678 124935 ...

output:

236620

result:

ok single line: '236620'

Test #7:

score: 0
Accepted
time: 438ms
memory: 207452kb

input:

9467
459 1670 1900 2977 4339 4824 7546 8996 9910 10014 11132 11270 11876 13176 13907 14235 14639 14644 15663 16031 16356 17025 17604 20184 20303 20659 22695 25734 26429 27163 27494 28103 28315 28642 29049 30611 30912 31204 35112 38485 38693 38819 39020 39856 40321 40507 41188 41456 41543 42569 43066...

output:

2366515

result:

ok single line: '2366515'

Test #8:

score: -100
Runtime Error

input:

5187
11371 81419 105299 108050 231495 240521 268631 278713 298294 336540 342336 353158 375299 412675 419605 435544 452566 480344 493285 518898 536360 548579 563170 579837 589116 603288 612545 619679 657372 676326 729118 742892 745265 745656 760690 801264 816179 829038 841628 842124 884009 909999 912...

output:


result: