이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |