Submission #3199253


Source Code Expand

Copy
#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  mp make_pair
typedef long long int ll;
const int N = 2e5+6,inf = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n,x;cin>>n>>x;
    int Arr[n+2];
    for(int i=1;i<=n;i++)
        cin>>Arr[i];
    sort(Arr+1,Arr+n+1);
    int Cnt = 0;
    for(int i=1;i<=n;i++)
    {
        if( x>=Arr[i] )x-=Arr[i],Cnt++;
    }
    if(x)cnt--;
    cout<<Cnt<< "\n";























    return 0;
}

Submission Info

Submission Time
Task A - Candy Distribution Again
User hrOarr
Language C++14 (GCC 5.4.1)
Score 0
Code Size 566 Byte
Status

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:10: error: ‘cnt’ was not declared in this scope
     if(x)cnt--;
          ^