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;
typedef long long ll;
int n, h[50];
ll k, g[50], ans;
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> h[i] >> g[i];
for (ll i = 1; i < (1 << n); i++) {
bool gd = 1;
int lst = -1;
ll sum = 0;
for (int j = 0; j < n; j++)
if (i & (1 << j)) {
if (lst != -1 && h[lst] > h[j])
gd = 0;
sum += g[j];
lst = j;
}
ans += gd * (sum >= k);
}
cout << ans;
}
# | 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... |