Language: C++

#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int n, m, w, t;
    cin >> n >> m >> w >> t;
    unordered_map<string, int> dic;
    vector<int> v(m);
    vector<int> p(m);
    for (int i = 0; i < m; ++i) {
        string s;
        cin >> s >> v[i] >> p[i];
        dic.insert({s, i});
    }
    vector<P> places(n);
    vector<vector<int>> prices(n, vector<int>(m, 10010));
    for (int i = 0; i < n; ++i) {
        int l, x, y;
        cin >> l >> x >> y;
        places[i] = P(x, y);
        for (int j = 0; j < l; ++j) {
            string s;
            int q;
            cin >> s >> q;
            prices[i][dic[s]] = q;
        }
    }
    vector<long long> dp(t + 1);
    for (int i = 1; i < (1 << n); ++i) {
        vector<int> towns;
        int sz = 0;
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) {
                towns.push_back(j);
                ++sz;
            }
        }
        int d = M;
        do {
            int dis = abs(places[towns[0]].first) + abs(places[towns[0]].second) + abs(places[towns[sz - 1]].first) + abs(places[towns[sz - 1]].second);
            for (int i = 0; i < sz - 1; ++i)
                dis += abs(places[towns[i + 1]].first - places[towns[i]].first) + abs(places[towns[i + 1]].second - places[towns[i]].second);

            d = min(d, dis);
        } while (next_permutation(towns.begin(), towns.end()));

        if (d > t) continue;

        vector<int> benef(m);
        for (auto& j : towns)
            for (int k = 0; k < m; ++k)
                benef[k] = max(benef[k], p[k] - prices[j][k]);

        vector<int> dp2(w + 1);
        for (int j = 0; j < m; ++j)
            for (int k = v[j]; k <= w; ++k)
                dp2[k] = max(dp2[k], dp2[k - v[j]] + benef[j]);

        dp[d] = max(dp[d], dp2[w]);
    }
    vector<int> inis;
    for (int i = 0; i <= t; ++i)
        if (dp[i] > 0)
            inis.push_back(i);

    for (int i = 1; i <= t; ++i) {
        dp[i] = max(dp[i], dp[i - 1]);
        for (auto& j : inis) {
            if (j >= i) continue;
            dp[i] = max(dp[i], dp[i - j] + dp[j]);
        }
    }
    cout << dp[t] << "\n";
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:61:20: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   61 |         dp[d] = max(dp[d], dp2[w]);
      |                 ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:61:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   61 |         dp[d] = max(dp[d], dp2[w]);
      |                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:61:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |         dp[d] = max(dp[d], dp2[w]);
      |                 ~~~^~~~~~~~~~~~~~~