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;
#define N 200005
int n, x, a[N], out;
vector<int> dp;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> x;
for (int i=1; i<=n; i++) cin >> a[i];
if (x==0) {
for (int i=1; i<=n; i++) {
auto idx = lower_bound(dp.begin(), dp.end(), a[i]);
if (idx == dp.end()) dp.push_back(a[i]);
else *idx = a[i];
}
cout << dp.size();
return 0;
}
for (int c=-x; c<=x; c++) {
for (int i=1; i<=n; i++) {
for (int j=i; j<=n; j++) {
dp.clear();
for (int k=1; k<=n; k++) {
int now;
now = (i<=k && k<=j) ? a[k]+c : a[k];
auto idx = lower_bound(dp.begin(), dp.end(), now);
if (idx == dp.end()) dp.push_back(now);
else *idx = now;
}
out = max(out, (int)dp.size());
}
}
}
cout << out;
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... |