Submission #1268458

#TimeUsernameProblemLanguageResultExecution timeMemory
1268458MMihalevBulldozer (JOI17_bulldozer)C++20
Compilation error
0 ms0 KiB
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAX_N=1e2+2;
int n;
long long x[MAX_N];
long long y[MAX_N];
long long cost[MAX_N];
vector<pair<long long,int>>order;
long long distance(long long A,long long B,long long C,long long x0,long long y0)
{
    return A*x0+B*y0+C;
}
long long solvefor()
{
    long long curbest=0;
    for(int i=0;i<order.size();i++)
    {
        long long cur=0;
        for(int j=i;j<order.size();j++)
        {
            cur+=cost[order[j].second];
        }
        curbest=max(curbest,cur);
    }
    return curbest;
}
void solve()
{
    for(int i=1;i<=n;i++)
    {
        order.push_back({x[i],i});
    }
    sort(order.begin(),order.end());
    long long ans=max(0LL,solvefor);
    cout<<ans<<"\n";
}
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>y[i]>>cost[i];
    }
    solve();
    return 0;
}

Compilation message (stderr)

bulldozer.cpp: In function 'void solve()':
bulldozer.cpp:37:22: error: no matching function for call to 'max(long long int, long long int (&)())'
   37 |     long long ans=max(0LL,solvefor);
      |                   ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:51,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from bulldozer.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:37:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long int()')
   37 |     long long ans=max(0LL,solvefor);
      |                   ~~~^~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:37:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long int()')
   37 |     long long ans=max(0LL,solvefor);
      |                   ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from bulldozer.cpp:3:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:37:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |     long long ans=max(0LL,solvefor);
      |                   ~~~^~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:37:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |     long long ans=max(0LL,solvefor);
      |                   ~~~^~~~~~~~~~~~~~