# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
473342 | AbdoMo | San (COCI17_san) | C++17 | 1071 ms | 2332 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.
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define pb push_back
const int mod = 1e9+7;
using namespace std;
bool comp(string a,string b)
{
if(a.size()==b.size())
{
return a<b;
}
return a.size()<b.size();
}
void solve(){
int n,k;
cin>>n>>k;
int arr[n][2];
int ans=0;
for(int i=0;i<n;i++)
{
cin>>arr[i][0]>>arr[i][1];
}
for(int mask=1;mask<(1<<n);mask++)
{
vector<int>v;
for(int i=0;i<(1<<n);i++)
{
if((mask&(1<<i)))
{
v.pb(i);
}
}
int x=0;
//cout<<v[0]<<" ";
int mx=0;
bool flag=0;
for(int i=0;i<v.size();i++)
{
//cout<<v[i]<<" ";
if(arr[v[i]][0]>=mx)
{
mx=arr[v[i]][0];
x+=arr[v[i]][1];
}
else
{
flag=1;
break;
}
}
if(flag==0 && x>=k)
{
//cout<<"up"<<endl;
ans++;
}
}
cout<<ans<<endl;
}
int32_t main(){
int t=1;
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// cin>>t;
while(t--){solve();}
return 0;
}
Compilation message (stderr)
# | 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... |