QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#485022#7695. Double UpFoedere0TL 0ms0kbC++141.0kb2024-07-20 10:32:362024-07-20 10:32:37

Judging History

This is the latest submission verdict.

  • [2024-07-20 10:32:37]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2024-07-20 10:32:36]
  • Submitted

answer

#include<bits/stdc++.h>
//#define int long long
using namespace std;
inline __int128 read(){
	__int128 x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
	    x=(x<<3)+(x<<1)+(c-'0');
	    c=getchar();
	}
	return x*f;
}
inline void write(__int128 x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar('0'+x%10);
}
int get(__int128 x){
	int cnt=0;
	while(x){
		x/=2;
		cnt++;
	}
	return cnt-1;
}
void solve(){
	int n;
	cin>>n;
	stack<int> heap;
	for(int i=1;i<=n;i++){
		__int128 x=read();
		int t=get(x);
		while(heap.size()&&heap.top()<t){
			heap.pop();
		}
		while(heap.size()&&heap.top()==t){
			heap.pop();
			t++;
		}
		heap.push(t);
	}
	int m;
	while(heap.size()){
		m=heap.top();
		heap.pop();
	}
	__int128 res=1;
	for(int i=1;i<=m;i++){
		res*=2;
		//write(res);
	}
	write(res);
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5
4 2 2 1 8

output:


result: