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 MAXN = 25;
int N,D,a[MAXN],ans;
bool marc[MAXN];
void bt(int i, int l)
{
if(i>N)
{
int cur=0;
for(int j = 1; j <= N; j++)
{
if(!marc[j])continue;
bool b = false;
for(int k = 1; k < j; k++)
if(marc[k] && a[k]>=a[j]){b=true; break;}
if(!b)cur++;
}
ans=max(ans,cur);
return;
}
if(i-l<D || l==0)bt(i+1,l);
marc[i]=true;
bt(i+1,i);
marc[i]=false;
return;
}
int main()
{
cin>>N>>D;
for(int i = 1; i <= N; i++)cin>>a[i];
bt(1, 0);
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... |