Submission #99910

#TimeUsernameProblemLanguageResultExecution timeMemory
99910aer0parkTaxis (POI13_tak)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n,m,d,anw=1,sum,id; vector<ll> x; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin>>m>>d>>n; for(int i=0;i<n;i++) { ll a;cin>>a; x.emplace_back(a); } sort(x.begin(),x.end()); id=lower_bound(x.begin(),x.end(),m-d)-x.begin(); if(id==n) { cout<<0; return 0; } if(m==d) anw=0,id=-1; // find x try to be exact ll i=n-1; while(sum<d&&i>=0) { if(i==id) { i--; continue; } if(x[i]-d+sum>0) sum+=x[i]-max(0,(d-sum)),anw++; i--; } if(sum<d) { cout<<0; return 0; } cout<<anw; return 0; }

Compilation message (stderr)

tak.cpp: In function 'int main()':
tak.cpp:39:27: error: no matching function for call to 'max(int, ll)'
    sum+=x[i]-max(0,(d-sum)),anw++;
                           ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from tak.cpp:1:
/usr/include/c++/7/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++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
tak.cpp:39:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
    sum+=x[i]-max(0,(d-sum)),anw++;
                           ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from tak.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
tak.cpp:39:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
    sum+=x[i]-max(0,(d-sum)),anw++;
                           ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from tak.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
tak.cpp:39:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    sum+=x[i]-max(0,(d-sum)),anw++;
                           ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from tak.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
tak.cpp:39:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    sum+=x[i]-max(0,(d-sum)),anw++;
                           ^