Codeforces Round #633 (Div. 2) C - Powered Addition 二分

//#include<bits/stdc++.h>
#include<map>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=1e5+10;
int a[N];
void work()
{
	int n=read();
	for(int i=1; i<=n; i++)
		a[i]=read();
	int ans=0;
	for(int i=2; i<=n; i++)
	{
		if(a[i-1]<=a[i])
			continue;
		int l=1,r=33;
		while(l<r)
		{
			int mid=(l+r)/2;
			int res=(1ll<<mid)-1;
			if(a[i-1]<=a[i]+res)
				r=mid;
			else
				l=mid+1;
		}
		ans=max(ans,l);
		a[i]=a[i-1];
	}
	printf("%d\n",ans);
}
signed main()
{
	int t;
	cin>>t;
	while(t--)
		work();
	return 0;
}


猜你喜欢

转载自www.cnblogs.com/QingyuYYYYY/p/12690006.html
今日推荐