Submission #473342

# Submission time Handle Problem Language Result Execution time Memory
473342 2021-09-15T12:27:09 Z AbdoMo San (COCI17_san) C++17
0 / 120
1000 ms 2332 KB
#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

san.cpp: In function 'void solve()':
san.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int i=0;i<v.size();i++)
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 2332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -