Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  hefdwehjfqw
Language: C/C++
Code:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

bool comp(int a ,int b)
{
 if(a<b)
  return 0;

 return 1;
}

int main()
{
int n;
vector<int< v;

cin>>n;
for(i=0;i<12;i++)
 {
 cin>>x;
 v.push_back(x);
}

sort( v.begin(),v.end(),comp );
int sm=0;
 for(i=0;i<12;i++)
   {
  sm+=v[i];
  if(sm>=n)
   break;
   }
cout<<i+1<<endl;
     return 0;
}
          
Comments: