이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int CeilIndex(vector<int>& v, int l, int r, int key)
{
while (r - l > 1) {
int m = l + (r - l) / 2;
if (v[m] >= key)
r = m;
else
l = m;
}
return r;
}
int lis(vector<int>& v)
{
if (v.size() == 0)
return 0;
vector<int> tail(v.size(), 0);
int length = 1;
tail[0] = v[0];
for (size_t i = 1; i < v.size(); i++) {
if (v[i] < tail[0])
tail[0] = v[i];
else if (v[i] > tail[length - 1])
tail[length++] = v[i];
else
tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i];
}
return length;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<int> s;
int n, x;
cin >> n >> x;
s.push_back(-x);
s.push_back(x);
vector<int> v;
for(int i = 0;i<n;i++) {
int p;
cin >> p;
v.push_back(p);
}
int MAX = lis(v);
if(x!=0) {
for(int i = 0;i<n;i++) {
for(int j = i;j<n;j++) {
for(int d = 0;d<=1;d++) {
for(int k = i;k<j;k++) {
v[k] += s[d];
}
MAX = max(MAX, lis(v));
for(int k = i;k<j;k++)v[k]-=s[d];
}
}
}
}
cout<<MAX<<endl;
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... |