Submission #3199504


Source Code Expand

Copy
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, x, cnt = 0;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    sort(a.begin(), a.end());
    for (int i = 0; i < n - 1; ++i) {
        x -= a.at(i);
        if (x < 0) break;
        ++cnt;
    }
    if (x == a.back()) ++cnt;
    cout << cnt << endl;
    return 0;
}

Submission Info

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

Compile Error

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