# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538361 | terrasphere | Global Warming (CEOI18_glo) | C++17 | 2087 ms | 4552 KiB |
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;
long long n,x;
long long LIS(vector<long long> vec)
{
vector<long long> lis;
for(int i=0;i<n;i++)
{
if(lis.empty() || lis.back()<vec[i])
lis.push_back(vec[i]);
else
lis[lower_bound(lis.begin(),lis.end(),vec[i])-lis.begin()]=vec[i];
}
return lis.size();
}
int main()
{
scanf("%lld%lld",&n,&x);
vector<long long> v;
v.resize(n);
for(int i=0;i<n;i++)
scanf("%lld",&v[i]);
long long answer=0;
if(x==0)
{
printf("%lld\n",LIS(v));
return 0;
}
for(int i=0;i<n;i++)
{
v[i]-=x;
answer=max(answer,LIS(v));
}
for(int i=0;i<n;i++)
v[i]+=x;
for(int i=n-1;i>0;i--)
{
v[i]+=x;
answer=max(answer,LIS(v));
}
printf("%lld\n",answer);
return 0;
}
Compilation message (stderr)
# | 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... |