Language: C++

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

using namespace std;

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

typedef __int64 ll;
typedef pair<ll,ll> pii;

const int N = 7;
const int M = 7;
const int W = 11111;
const int T = 11111;
const ll INF = 1e16;

int n,m,w,t;

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

map<string,int> dict;


bool Contain(int state, int i){
	return (state&(1<<i))>0;
}


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

void InitMemo(){
	rep(i,(1<<N))rep(j,N)memo[i][j]=-1;
}


ll GetRoot(int state, int num){
	if(state==0)return 0;
	if(state==(1<<num))return abs(pos[num].f) + abs(pos[num].s);
	if(memo[state][num]!=-1)return memo[state][num];
	
	ll ret = INF;
	
	state -= (1<<num);
	
	rep(i,n){
		if(Contain(state,i)){
			int dist = abs(pos[num].f - pos[i].f) + abs(pos[num].s - pos[i].s);
			ret = min(ret, GetRoot(state, i) + dist);
		}
	}
	
	
	return memo[state][num] = ret;
}

ll GetTime(int state){
	
	if(state==0)return false;
	
	ll ans = INF;
	
	rep(i,n){
		if(Contain(state,i)){
			ans = min(ans, GetRoot(state,i) + abs(pos[i].f)+abs(pos[i].s));
		}
	}
	
	return ans;
}


ll GetValue(int state){
	
	int has[M] = {0};
	
	rep(i,n){
		if(!Contain(state,i))continue;
		rep(j,m){
			has[j] = max(has[j], shop[i][j]);
		}
	}
	
	
	ll dp[W]={0};
	ll ans = 0;
	
	rep(i,w+1){
		rep(j,m){
			if(i+item[j].f > w)continue;
			dp[(int)(i+item[j].f)] = max(dp[(int)(i+item[j].f)], dp[i]+has[j]);
			
		}
		ans = max(ans, dp[i]);
	}
	
	return ans;
}


vector<pii> GetCand(){
	
	vector<pii> ret;
	
	rep(i,(1<<n)){
		ll a = GetTime(i);
		ll b = GetValue(i);
		
		if(a>=INF)continue;
		ret.push_back(pii(a,b));
	}
	
	return ret;
}

ll solve(){
	vector<pii> cand = GetCand();
	
	/*
	rep(i,cand.size()){
		cout<<"***"<<cand[i].f<<" "<<cand[i].s<<endl;
	}
	*/
	
	
	ll dp[T] = {0};
	ll ans = 0;
	rep(i,t+1){
		rep(j,cand.size()){
			int a = cand[j].f;
			int b  =cand[j].s;
			if(i+a>t)continue;
			dp[i+a] = max(dp[i+a], dp[i]+b);
			
		}
		ans = max(ans,dp[i]);
	}
	
	return ans;
}


bool input(){
	cin>>n>>m>>w>>t;
	
	rep(i,m){
		string s;
		cin>>s>>item[i].f>>item[i].s;
		
		dict[s] = i;
	}
	
	rep(i,n){
		int a;
		cin>>a;
		cin>>pos[i].f>>pos[i].s;
		rep(j,m)shop[i][j]=0;
		rep(j,a){
			string s;
			int p;
			cin>>s>>p;
			int num = dict[s];
			shop[i][num] = item[num].s-p;
		}
	}
	
	
	return true;
}


int main(){
	
	InitMemo();
	
	
	input();
	
	
	cout<<solve()<<endl;
}

Compiler output:
a.cc:16:9: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | typedef __int64 ll;
      |         ^~~~~~~
      |         __int64_t
a.cc:17:14: error: 'll' was not declared in this scope
   17 | typedef pair<ll,ll> pii;
      |              ^~
a.cc:17:17: error: 'll' was not declared in this scope
   17 | typedef pair<ll,ll> pii;
      |                 ^~
a.cc:17:19: error: template argument 1 is invalid
   17 | typedef pair<ll,ll> pii;
      |                   ^
a.cc:17:19: error: template argument 2 is invalid
a.cc:23:7: error: 'll' does not name a type
   23 | const ll INF = 1e16;
      |       ^~
a.cc:39:1: error: 'll' does not name a type
   39 | ll memo[(1<<N)][N];
      | ^~
a.cc: In function 'void InitMemo()':
a.cc:42:30: error: 'memo' was not declared in this scope
   42 |         rep(i,(1<<N))rep(j,N)memo[i][j]=-1;
      |                              ^~~~
a.cc: At global scope:
a.cc:46:1: error: 'll' does not name a type
   46 | ll GetRoot(int state, int num){
      | ^~
a.cc:66:1: error: 'll' does not name a type
   66 | ll GetTime(int state){
      | ^~
a.cc:82:1: error: 'll' does not name a type
   82 | ll GetValue(int state){
      | ^~
a.cc: In function 'std::vector<int> GetCand()':
a.cc:115:17: error: 'll' was not declared in this scope
  115 |                 ll a = GetTime(i);
      |                 ^~
a.cc:116:19: error: expected ';' before 'b'
  116 |                 ll b = GetValue(i);
      |                   ^~
      |                   ;
a.cc:118:20: error: 'a' was not declared in this scope
  118 |                 if(a>=INF)continue;
      |                    ^
a.cc:118:23: error: 'INF' was not declared in this scope
  118 |                 if(a>=INF)continue;
      |                       ^~~
a.cc:119:35: error: 'a' was not declared in this scope
  119 |                 ret.push_back(pii(a,b));
      |                                   ^
a.cc:119:37: error: 'b' was not declared in this scope
  119 |                 ret.push_back(pii(a,b));
      |                                     ^
a.cc:119:38: error: expression list treated as compound expression in functional cast [-fpermissive]
  119 |                 ret.push_back(pii(a,b));
      |                                      ^
a.cc: At global scope:
a.cc:125:1: error: 'll' does not name a type
  125 | ll solve(){
      | ^~
a.cc: In function 'bool input()':
a.cc:13:11: error: request for member 'first' in 'item[i]', which is of non-class type 'pii' {aka 'int'}
   13 | #define f first
      |           ^~~~~
a.cc:157:33: note: in expansion of macro 'f'
  157 |                 cin>>s>>item[i].f>>item[i].s;
      |                                 ^
a.cc:14:11: error: request for member 'second' in 'item[i]', which is of non-class type 'pii' {aka 'int'}
   14 | #define s second
      |           ^~~~~~
a.cc:157:44: note: in expansion of macro 's'
  157 |                 cin>>s>>item[i].f>>item[i].s;
      |                                            ^
a.cc:13:11: error: request for member 'first' in 'pos[i]', which is of non-class type 'pii' {aka 'int'}
   13 | #define f first
      |           ^~~~~
a.cc:165:29: note: in expansion of macro 'f'
  165 |                 cin>>pos[i].f>>pos[i].s;
      |                             ^
a.cc:14:11: error: request for member 'second' in 'pos[i]', which is of non-class type 'pii' {aka 'int'}
   14 | #define s second
      |           ^~~~~~
a.cc:165:39: note: in expansion of macro 's'
  165 |                 cin>>pos[i].f>>pos[i].s;
      |                                       ^
a.cc:14:11: error: request for member 'second' in 'item[num]', which is of non-class type 'pii' {aka 'int'}
   14 | #define s second
      |           ^~~~~~
a.cc:172:50: note: in expansion of macro 's'
  172 |                         shop[i][num] = item[num].s-p;
      |                                                  ^
a.cc: In function 'int main()':
a.cc:189:15: error: 'solve' was not declared in this scope
  189 |         cout<<solve()<<endl;
      |               ^~~~~