이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define lesgooo ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
signed main()
{
lesgooo;
int n, x;
cin >> n >> x;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
int dp[n][2]{};
for (int i = n-1; i >= 0; i--) for (int j = 0; j < 2; j++)
{
for (int k = i + 1; k < n; k++) if (a[i] < a[k]) dp[i][j] = max(dp[i][j], dp[k][j]);
if (!j) for (int k = i + 1; k < n; k++) if (a[i]+1-a[k] <= x && -a[i]-1+a[k] <= x) dp[i][j] = max(dp[i][j], dp[k][1]);
dp[i][j]++;
}
int mx = 0;
for (int i = 0; i < n; i++) mx = max(mx, dp[i][0]);
cout << mx;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |