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;
typedef vector<int> vi;
#define MAXI (int)1e5
#define pb(x) push_back(x)
vector<int> ad[MAXI];
vector<bool> vis(MAXI,0);
map<pair<int,int>,int> m;
void dfs(int x){
if(vis[x]) return;
vis[x] = 1;
for(auto s:ad[x]){
dfs(s);
}
}
int lis(vector<int> const& a) {
int n = a.size();
const int INF = 1e9;
vector<int> d(n+1, INF);
d[0] = -INF;
for (int i = 0; i < n; i++) {
int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
if (d[j-1] < a[i] && a[i] < d[j])
d[j] = a[i];
}
int ans = 0;
for (int i = 0; i <= n; i++) {
if (d[i] < INF)
ans = i;
}
return ans;
}
int main(){
int n,x; cin >> n >> x;
x *=-1;
int maxi = 0;
vector<int> a(n,0);
for(int i = 0;i<n;i++) cin >> a[i];
for(int i = 0;i<n;i++){
vector<int> b(a);
for(int j = i;j<n;j++){
b[j] +=x;
maxi = max(maxi,lis(b));
}
}
cout << maxi;
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... |