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;
using ll = long long;
#define all(v) (v).begin(), v.end()
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n, x;
cin >> n >> x;
vector<int> a(n);
for (auto &i : a)
cin >> i;
if (!x) {
vector<int> v;
for (int i = 0; i < n; i++) {
if (v.empty() || v.back() < a[i]) v.push_back(a[i]);
else v[lower_bound(all(v), a[i]) - v.begin()] = a[i];
}
return cout << (int)v.size(), 0;
}
int ans = 0;
vector<int> v;
for (int i = 0; i < n; i++) {
vector<int> u = v;
for (int j = i; j < n; j++) {
a[j] += x;
if (u.empty() || u.back() < a[j]) u.push_back(a[j]);
else u[lower_bound(all(u), a[j]) - u.begin()] = a[j];
a[j] -= x;
}
ans = max(ans, (int)u.size());
if (v.empty() || v.back() < a[i]) v.push_back(a[i]);
else v[lower_bound(all(v), a[i]) - v.begin()] = a[i];
}
cout << ans << '\n';
}
# | 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... |