Language: C++

#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<vector>
#include<cassert>

using namespace std;

#define int long long
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define f first
#define s second

typedef pair<int,int> pii;

const int N = 8;
const int M = 8;
const int W = 21111;
const int T = 21111;
const int INF = 1e16;
int n,m,w,t;

map<string, int> dict;
pii  item[M];

pii pos[N];
int shop[N][M];


int memo[(1<<N)][N];


void memoInit(){
	for(int i=0;i<(1<<N);i++)rep(j,N)memo[i][j]=-1;
}
int Root(int state, int num){

	if(state==0)return 0;

	if(memo[state][num]!=-1)return memo[state][num];
	if(state==(1<<num))return abs(pos[num].f) + abs(pos[num].s);
	state &= ~(1<<num);

	int ans = INF;
	for(int i=0;i<n;i++){
		if((state & (1<<i)) > 0){
			int dist = abs(pos[num].f - pos[i].f) + abs(pos[num].s - pos[i].s);
			ans = min(ans, Root(state, i) + dist);
		}
	}

	return memo[state][num] = ans ;
}

int GetTime(int state){


	int ans = INF;
	for(int i=0;i<n;i++){

		if( (state&(1<<i))>0 ) {
			int r  = Root(state,i);
			ans = min(ans, r + abs(pos[i].f) + abs(pos[i].s));
		}
	}
	return ans;
}

int GetValue(int state){
	
	
	int has[M] = {0};
	rep(i,M)has[i] = INF;

	rep(i,n){
		if((state&(1<<i)) > 0){
			rep(j,m){
				if(shop[i][j]!=-1){
					has[j] = min(has[j], shop[i][j]);
				}
			}
		}
	}


	int dp[W] = { 0};

	int ans = 0;
	for(int i=0;i<w+1;i++){

		rep(j,7){
			if(has[j]==INF)continue;
			int wi = item[j].f;
			int vi = has[j];

			dp[i+wi] = max(dp[i+wi], dp[i] + vi);
			ans = max(ans, dp[i]);
		}
	}

	return ans;
}

vector<pii> GetCand(){

	vector<pii> cand;
	for(int i=0;i<(1<<n);i++){
		cand.push_back(pii(GetTime(i), GetValue(i)));
	}
	return cand;
}

int dp[T] = {0};

int solve(){

	vector<pii> cand = GetCand();

	for(int i=0;i<cand.size();i++){
		//printf("*** %lld %lld\n",cand[i].f, cand[i].s);
	}
	rep(i,T)dp[i]=0;


	int ans = 0;
	rep(i,t+1){
		rep(j,cand.size()){
			pii c = cand[j];
			if(i+c.f >= T){
				continue;
			}

			dp[i + c.f] = max(dp[i+c.f], dp[i] + c.s);
			ans = max(ans, dp[i]);
		}
	}

	return ans;
}

signed main(){
	memoInit();
	cin>>n>>m>>w>>t;

	rep(i,m){
		string s;
		int a,b;
		cin>>s>>a>>b;
		dict[s] = i;
		item[i] = pii(a,b);
	}

	rep(i,N)rep(j,M)shop[i][j] = -1;

	rep(i,n){
		int a,x,y;
		cin>>a>>x>>y;
		pos[i] = pii(x,y);

		rep(j,M)shop[i][j]=-1;
		rep(j,a){
			string s;
			int p;
			cin>>s>>p;
			int num = dict[s];
			shop[i][num] = max(0, item[num].s-p);
		}
	}

	cout<<solve()<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:170:43: error: no matching function for call to 'max(int, long long int)'
  170 |                         shop[i][num] = max(0, item[num].s-p);
      |                                        ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/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:170:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  170 |                         shop[i][num] = max(0, item[num].s-p);
      |                                        ~~~^~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:6:
/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:170:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  170 |                         shop[i][num] = max(0, item[num].s-p);
      |                                        ~~~^~~~~~~~~~~~~~~~~~