Submission #3199103


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<17;
   

int main(){
    int N;
    LL x;
    cin >> N >> x;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(ALL(a));
    int ans=0;
    for(int i=0;i<N;i++){
        x-=a[i]; 
        if(x>=0) ans++;
        else break;
    } 
    if(x>0) ans--;
    cout << ans << endl;
    return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:18: error: request for member ‘begin’ in ‘a’, which is of non-class type ‘LL [N] {aka long long int [N]}’
 #define ALL(A) A.begin(),A.end()
                  ^
./Main.cpp:25:10: note: in expansion of macro ‘ALL’
     sort(ALL(a));
          ^
./Main.cpp:8:28: error: request for member ‘end’ in ‘a’, which is of non-class type ‘LL [N] {aka long long int [N]}’
 #define ALL(A) A.begin(),A.end()
                            ^
./Main.cpp:25:10: note: in expansion of macro ‘ALL’
     sort(ALL(a));
          ^