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;
long long n,k;
vector<pair<long long,long long>> arr(42);
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>k;
for(int i = 0;i<n;i++){
long long a,b;cin>>a>>b;
arr[i] = {a,b};
}
arr[40]={0,0};
long long ans = 0;
if(n<=20){
for(long long mask=0;mask<(1<<n);mask++){
long long s=0,p=40;
for(long long i=0;i<n;i++){
if((1<<i)&mask){
if(arr[i].first>=arr[p].first){
s+=arr[i].second;
}
else{
s=-1;
break;
}
p=i;
}
}
if(s>=k)ans++;
}
}
cout<<ans;
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... |