CF1987C 题解
思路
正难则反。设
代码
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int t, n, a[100005];
ll dp[100005];
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> t;
while (t --) {
cin >> n;
dp[n] = 0;
for (int i = 0; i < n; ++ i)
cin >> a[i];
for (int i = n - 1; ~i; -- i)
dp[i] = a[i] > dp[i + 1] ? a[i] : dp[i + 1] + 1;
cout << dp[0] << '\n';
}
return 0;
}