Submission #3199863


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807LL;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<=i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n-1)
#define append(a)      push_back(a)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0),cout<<fixed<<setprecision(10);}

signed main(){
    ll N,M,S=0,T=0;
    cin>>N>>M;
    ll A[N];
    rep(i,N)cin>>A[i];
    sort(A,A+N);
    rep(i,N){
        if(M>A[i]){
            M-=A[i];
            S++;
        }
        else if(M==A[i]){
            S++;
            T++;
            break;
        }
        else break;
    }
    if(T==0)S--;
    cout<<max(S,0)<<endl;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:18: error: no matching function for call to ‘max(ll&, int)’
     cout<<max(S,0)<<endl;
                  ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
./Main.cpp:40:18: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
     cout<<max(S,0)<<endl;
  ...