90分,救命!
  • 板块P1799 数列
  • 楼主abensyl
  • 当前回复8
  • 已保存回复8
  • 发布时间2022/8/24 22:06
  • 上次更新2023/10/27 13:48:22
查看原帖
90分,救命!
641163
abensyl楼主2022/8/24 22:06
#include <bits/stdc++.h>

using namespace std;

const int N = 1e3 + 2;

int a[N];
int f[N];
int n;
int res;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i)
    for (int j = i; j >= 1; --j) {
      f[j] = max(f[j - 1], f[j] + (i - j == a[i]));
      res = max(res, f[j]);
    }
  cout << res;
  return 0;
}
2022/8/24 22:06
加载中...