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>
#define MAX (int)(1e4 + 5)
#define ll long long
#define esq(x) (x<<1)
#define dir(x) ((x<<1)|1)
using namespace std;
int n, k;
ll h[MAX], tmp, resp, maior;
int main()
{
cin >> n >> k;
for (int i = 0; i < n; i++)
{
cin >> h[i];
}
for (int i = 1; i < (1<<n); i++)
{
ll maior = -1, tmp = 0, last = -1;
for (int j = 0; j < n; j++)
{
if (i&(1<<j))
{
if (h[j] > maior) tmp++, maior = h[j];
if (j-last > k && last!=-1) tmp = -1000000000;
last = j;
}
}
resp = max(resp, tmp);
}
cout << resp << endl;
}
# | 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... |