제출 #1348856

#제출 시각아이디문제언어결과실행 시간메모리
1348856ramzialoulouFinancial Report (JOI21_financial)C++20
48 / 100
63 ms544 KiB
#include <bits/stdc++.h>
 
using namespace std;

const int N = 7009;
const int LOG = 20;
int a[N];
int dp[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    vector<int> last(1, i);
    for (int j = i - 1; j >= 0; j--) {
      if (a[j] < a[i]) {
        if (last.back() - j > d) {
          break;
        }
        last.push_back(j);
        dp[i] = max(dp[i], dp[j] + 1);
      }

    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << '\n';
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...