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;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
// jangan kebiasa kalah
// kalo OI, sampah aja dulu, tapi jangan menutup kemungkinan buat AC
long long n,x,arr[200069],ans,dp[200069];
long long lis()
{
long long i,j;
vector<long long> tmp(n+5,1e18);
tmp[0] = -1e18;
for(i=1;i<=n;i++)
{
j = upper_bound(tmp.begin(),tmp.end(),arr[i])-tmp.begin();
if(tmp[j-1] < arr[i] and arr[i] < tmp[j])
{
tmp[j] = arr[i];
}
}
j = 0;
for(i=1;i<=n;i++)
{
if(tmp[i] < 1e18)
{
j = i;
}
}
return j;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long i,j,s;
cin>>n>>x;
for(i=1;i<=n;i++)
{
cin>>arr[i];
}
if(x == 0ll)
{
ans = lis();
cout<<ans<<'\n';
return 0;
}
if(n <= 10 and x <= 10)
{
long long l,r;
ans = 1;
for(s=-x;s<=x;s++)
{
for(l=1;l<=n;l++)
{
for(r=l;r<=n;r++)
{
long long tmp[n+1];
tmp[0] = 0;
for(i=1;i<=n;i++)
{
tmp[i] = arr[i];
if(l <= i and i <= r)
{
tmp[i] += s;
}
dp[i] = 1;
}
for(i=2;i<=n;i++)
{
for(j=1;j<i;j++)
{
if(tmp[i] > tmp[j] and dp[i] < dp[j]+1)
{
dp[i] = dp[j]+1;
}
}
ans = max(ans,dp[i]);
}
}
}
}
cout<<ans<<'\n';
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... |