Submission #886488

# Submission time Handle Problem Language Result Execution time Memory
886488 2023-12-12T08:26:28 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()

int main(){
    ll n;
    cin>>n;

    vector<ll> a(n), b(n), x(n);
    for(auto &e:a) cin>>e;
    for(auto &e:b) cin>>e;

    iota(all(x), 0);
    sort(all(x), [&](ll l, ll r){
        return (b[l]-a[r]<min({b[l], b[r], b[r]-a[l]}));
    });

    ll ans=0;
    for(ll mask=0; mask<(1<<n); mask++){
        bool f=1;
        ll cur=0;
        for(ll i=0; i<n; i++){
            if(mask&(1<<i)){
                if(cur<=b[i]){
                    cur+=a[i];
                }
                else{
                    f=0;
                    break;
                }
            }
        }
        if(f) ans=max(ans, __builtin_popcount(mask));
    }

    cout<<ans<<endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:36:52: error: no matching function for call to 'max(long long int&, int)'
   36 |         if(f) ans=max(ans, __builtin_popcount(mask));
      |                                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:36:52: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |         if(f) ans=max(ans, __builtin_popcount(mask));
      |                                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:36:52: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |         if(f) ans=max(ans, __builtin_popcount(mask));
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Main.cpp:36:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |         if(f) ans=max(ans, __builtin_popcount(mask));
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Main.cpp:36:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |         if(f) ans=max(ans, __builtin_popcount(mask));
      |                                                    ^