求调
查看原帖
求调
966300
Stardust_Mirage楼主2025/7/18 18:26

P12836

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a[250005],ans,t[250005];
int ad[50];
int lg(int x){
	return lower_bound(ad,ad+40,x)-ad;
}
signed main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n; 
    ad[0]=1;
    for(int i=1;i<=40;i++)ad[i]=ad[i-1]*2;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=2,x;i<=n;i++){
    	t[i]=t[i-1];
		if(a[i]>a[i-1]){
			int l=0;
			while(double(1.0/(1<<(l+1)))-double(a[i-1]*1.0/a[i])>=0)l++;
			t[i]=max(0ll,t[i]-l);
			ans+=t[i];
		}
		else {
			int l=lg(1ll*(a[i-1]+a[i]-1)/a[i]);
			t[i]+=l;
			ans+=t[i];
		}
	}
	cout<<ans;
    return 0;
}

WA了最后一个点 一直调不出来

2025/7/18 18:26
加载中...