Submission #3199723


Source Code Expand

Copy
#include <iostream>
using namespace std;

int main() {
    int32_t n;
    int64_t x;
    cin >> n >> x;
    int32_t a[n];

    for (int32_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);

    for (int32_t i = 0; i < n; i++) {
        x -= a[i];
        if (x < 0) {
            cout << i << endl;
            return 0;
        }
    }
    if (x == 0) {
        cout << n << endl;
    } else {
        cout << n - 1 << endl;
    }

    return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:18: error: ‘sort’ was not declared in this scope
     sort(a, a + n);
                  ^