This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int lg2(int x) {
return 31 - __builtin_clz(x);
}
main() {
#ifdef Home
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // Home
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d;
cin >> n >> d;
int arr[n];
for(int i = 0; i < n; ++ i) {
cin >> arr[i];
}
int ans = 0;
for(int msk = (1<<n); msk --> 0;) {
int k = 0, tmp = msk, pr = -1, cr, mx = -1;
for(; tmp; tmp -= (-tmp&tmp)) {
cr = lg2(-tmp&tmp);
if(pr != -1 && cr - pr > d) {
k = 0;
break;
}
if(mx < arr[cr]) {
++ k;
mx = arr[cr];
}
pr = cr;
}
if(pr == n - 1) {
ans = max(ans, k);
}
}
cout << ans;
}
Compilation message (stderr)
Main.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
16 | main() {
| ^~~~
# | 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... |