#include <cstdio>
#include <cstring>
#include <algorithm>
struct pair {
int x, y;
explicit pair (int x = 0, int y = 0) : x(x), y(y) {}
bool operator < (const pair &o) const {
return x != o.x ? x < o.x : y > o.y;
}
};
const int N = 1000000 + 7;
pair b[N];
int a[N], c[N], n;
int main() {
// freopen("game.in", "r", stdin);
// freopen("game.out", "w", stdout);
int x, y, z, m = 0, cnt;
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
if(i >= a[i]) b[++m] = pair(a[i], i - a[i]);
}
std::sort(b + 1, b + m + 1);
c[cnt = 1] = b[1].y;
for(int i = 2; i <= m; ++i)
if(b[i].y >= c[cnt]) c[++cnt] = b[i].y;
else *std::upper_bound(c + 1, c + cnt + 1, b[i].y) = b[i].y;
printf("%d\n", cnt);
return 0;
}
老师写的代码,有没有dalao告诉一下"upper_bound"是怎么用的啊,复制过去后老是报错