# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
811998 | vjudge1 | Financial Report (JOI21_financial) | C++17 | 0 ms | 0 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.
#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;
for(int tmp = msk, pr = -1, cr, mx = 0; 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;
}