思路
问题等价于找到一个\(b\)数组,使得
ac代码
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 inf = 1e18;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
void solve() {
int n;
cin >> n;
vector<i64> a(n + 1), b(n + 1, 0);
i64 ans = 0;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 2; i <= n; i++) {
b[i] = max(0ll, b[i - 1] + a[i - 1] - a[i]);
if (b[i]) ans = max(ans, __lg(b[i]) + 1);
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t --) solve();
return 0;
}
标签:const,Powered,Addition,i64,int,_-,CF1338A
From: https://www.cnblogs.com/kichuan/p/17973547