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>
using namespace std;
constexpr int INF = 0x3f3f3f3f;
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int n, x; cin >> n >> x;
vector<int> t(n + 1); t[0] = -INF;
for (int i = 1; i <= n; i++) cin >> t[i];
vector dp(n + 1, vector<int>(2, 0));
for (int i = 1; i <= n; i++) {
for (int j = 0; j < i; j++) {
if (t[j] < t[i]) {
dp[i][0] = max(dp[i][0], dp[j][0] + 1);
dp[i][1] = max(dp[i][1], dp[j][1] + 1);
}
if (t[j] < t[i] + x) dp[i][1] = max(dp[i][1], dp[j][0] + 1);
}
}
cout << max(dp[n][0], dp[n][1]) << '\n';
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... |