Thursday, 3 October 2013

Mark And Toys Solution Hackerrank

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int s=0,i=0;
    while(s<=k)
    {
        s+=a[i];
        i++;
    }
    cout<<i-1<<endl;
    return 0;
}

1 comment:

  1. Pokies Casino - New Jersey
    Pokies Casino is the newest and 벳 매니아 fastest-growing 온카 casino online. Get an 365 bet exciting online 벳 티비 casino experience with online Pokies at the best NJ 바카라 몬 casinos. Get your

    ReplyDelete

Chocolate Feast Solution Hackerrank

#include<iostream> using namespace std; int main() {     int t;     cin>>t;     while(t--)     {         int n,c,m,w,tot...