Submission #3199912


Source Code Expand

Copy
#include <iostream>
#include <vector>

using namespace std;


int main() {
    int N, X; cin >> N >> X;
    vector<int> A(N); for(int &a:A) cin >> a;
    sort(A.begin(), A.end());
    
    int ans = 0;
    for(int i=0; i<N; i++){
        if(X>=A[i]){
            ans++;
            X -= A[i];
        } else break;
    }
    
    if(X>0 && ans) cout << ans-1 << endl;
    else cout << ans << endl;

    return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:28: error: ‘sort’ was not declared in this scope
     sort(A.begin(), A.end());
                            ^