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;
const int k_N = 2e5 + 3;
const int k_Inf = 1e9 + 3;
int n, x;
int t[k_N];
int get_lis(){
vector<int> dp;
dp.push_back({-k_Inf});
for(int i = 0; i < n; ++i){
auto it = lower_bound(dp.begin(), dp.end(), t[i]);
if(it == dp.end())
dp.push_back(t[i]);
else
dp[it - dp.begin()] = t[i];
}
return (int)dp.size() - 1;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> x;
for(int i = 0; i < n; ++i)
cin >> t[i];
int ans = 0, l = 0;
for(int r = l; r < n; ++r){
int d = -x;
for(int i = l; i <= r; ++i)
t[i] += d;
ans = max(get_lis(), ans);
for(int i = l; i <= r; ++i)
t[i] -= d;
}
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... |