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;
#define MAXN 25
int h[MAXN], g[MAXN];
int main(){
int n;
long long s;
cin >> n >> s;
for(int i=1; i<=n; i++){
cin >> h[i] >> g[i];
}
long long ans=0;
for(int i=0; i<(1<<n); i++){
int u = i;
int ant=0;
bool ok=1;
long long sum = 0;
for(int j=1; j<=20; j++){
if(u%2==1){
if(h[j]>=h[ant]){
sum+=g[j];
ant=j;
}
else{
ok=0;
break;
}
}
u = u/2;
}
if(ok==1){
if(sum>=s){
ans++;
}
}
}
cout << ans << endl;
return 0;
}
# | 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... |