Falling Concrete
Falling Concrete
\(bj = aj - j = aj - (j - i) - i\)
发现不变量
对于一个bi,可以放在任意位置,放在k的值为\(b_i+k\),要\(b_i+k\)平滑,就要\(b_{i-1} + k_{i-1} = b_i + k_i\)
因为\(k_i = k_{i-1} + 1\), 所以\(b_{i-1} = b_i + 1\)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n; cin >> n;
vector<int> b(n);
for(int i = 0; i < n; i ++) {
int x; cin >> x;
b[i] = x - (i + 1);
}
sort(b.begin(), b.end());
b.erase(unique(b.begin(), b.end()), b.end());
int cur = 1, ans = 1;
for(int i = 1; i < b.size(); i ++) {
if(b[i] == b[i-1]+1) cur ++;
else cur = 1;
ans = max(cur, ans);
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int _ = 1; cin >> _;
while(_--) solve();
return 0;
}

浙公网安备 33010602011771号