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 ll long long
ll findlis(vector<ll> v, ll x, ll prev){
ll sz = v.size();
if(x == sz) return 0;
if(x == sz-1){
return findlis(v, x+1, prev);
}
if(prev == -1) return max(findlis(v, x+1, -1), findlis(v, x+1, x+1)+1);
if(v[prev] < v[x+1]) return max(findlis(v, x+1, prev), findlis(v, x+1, x+1)+1);
return findlis(v, x+1, prev);
}
int main(){
vector<ll> t, temp;
ll n, x, input, maxlis = 0;
cin >> n >> x;
for(int i = 0; i < n; i++){
cin >> input;
t.push_back(input);
}
if(x == 0){
cout << findlis(t, 0, -1) << endl;
return 0;
}
for(int k = x*(-1); k <= x; k++){
for(int l = 0; l < n; l++){
temp = t;
for(int r = l; r < n; r++){
temp[r] += k;
maxlis = max(maxlis, findlis(temp, 0, -1));
}
}
}
cout << maxlis;
}
# | 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... |