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;
typedef long long ll;
ll p1 = 27644437;
ll p2 = 1000000007;
int LIS(int n, ll a[]) {
const ll INF = 1e18;
vector<ll> d(n+1, INF);
d[0] = -INF;
for (int i = 0; i < n; i++) {
int l = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
if (d[l-1] < a[i] && a[i] < d[l])
d[l] = a[i];
}
int ans = 0;
for (int l = 0; l <= n; l++) {
if (d[l] < INF)
ans = l;
}
return ans;
}
void solve() {
int n, x; cin >> n >> x;
ll a[n+1];
for(int i=0;i<n;i++) {
cin >> a[i];
}
if(x == 0) {
cout << LIS(n, a) << endl;
}else{
int ans = 1;
x=abs(x);
for(int i=0;i<n;i++) {
for(int j=i;j<n;j++) {
for(int d=-x;d<=x;d++) {
for(int k=i;k<=j;k++) {
a[k]+=d;
}
ans = max(ans, LIS(n, a));
for(int k=i;k<=j;k++) {
a[k]-=d;
}
}
}
}
cout << ans << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
// int t; cin >> t;
// while(t--)
solve();
char dksfjn;
cin >> dksfjn;
}
# | 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... |