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 ll long long
#define ld long double
#define pb push_back
using namespace std;
const ll maxn = 1e5 + 1;
ll n, k, H[41], G[41], a, cur, ans;
main ()
{
cin >> n >> k;
for (ll i = 1; i <= n; i ++)
{
cin >> H[i] >> G[i];
}
for (ll mask = 0; mask < pow (2, n); mask ++)
{
cur = 0, a = 0;
for (ll i = 1; i <= n; i ++)
{
if ((mask >> (i - 1)) % 2 == 1)
{
if (cur <= H[i])
{
a += G[i];
cur = H[i];
}
else
{
a = 0, cur = 0;
break;
}
}
}
if (a >= k)
ans ++;
}
cout << ans;
}
Compilation message (stderr)
san.cpp:8:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | 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... |