Horje
convert c code to java online free Code Example
convert c code to java online free
#include<iostream>
#include<algorithm>
using namespace std;
int cmp(int &a,int &b)
{
    return a>b;
}
int main()
{
    int n;
    long int b;
    long int sum;
    int i;
    int count;
    int cows[20000];
    cin>>n>>b;
    for(i=0;i<n;i++)
        cin>>cows[i];
    sort(cows,cows+n,cmp);
    sum=0;
    count=0;
    for(i=0;i<n;i++)
    {
        if(sum>=b)
            break;
        sum+=cows[i];
        count++;
    }
    cout<<count<<endl;
    return 0;
}




Cpp

Related
unknown amount of threads cpp Code Example unknown amount of threads cpp Code Example
c++ correct upto 3 decimal places Code Example c++ correct upto 3 decimal places Code Example
vector and algorithm Code Example vector and algorithm Code Example
Marin and Anti-coprime Permutation codeforces solution in c++ Code Example Marin and Anti-coprime Permutation codeforces solution in c++ Code Example
walk filesystem in c++ Code Example walk filesystem in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10