This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
void fun() {
int n, x;
cin >> n >> x;
int arr[n + 1];
arr[0] = 0;
for (int i = 1; i <= n; ++i) {
cin >> arr[i];
}
int mx = 1;
for (int i = -x; i <= +x; ++i) {
int dp[n + 1][3];
dp[0][0] = 0;
dp[0][1] = 0;
dp[0][2] = 0;
for (int j = 1; j <= n; ++j) {
dp[j][0] = dp[j][1] = dp[j][2] = 1;
for (int k = 0; k < j; ++k) {
if (arr[j] > arr[k]) {
dp[j][0] = max(dp[j][0], dp[k][0] + 1);
dp[j][1] = max(dp[j][1], dp[k][1] + 1);
dp[j][2] = max(dp[j][2], dp[k][2] + 1);
}
if (arr[j] + i > arr[k]) {
dp[j][1] = max(dp[j][1], dp[k][0] + 1);
}
if (arr[j] > arr[k + 5]) {
dp[j][2] = max(dp[j][2], dp[k][1] + 1);
}
}
mx = max(mx, max(max(dp[j][0], dp[j][1]), dp[j][2]));
}
}
cout << mx << "\n";
}
int32_t main() {
fun();
}
# | 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... |