Language: C++

#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Goods{
public:
	short w;
	short p;
	Goods(short _w,short _p) : w(_w), p(_p) {}
};

short dp[101][5001];
const static short MAX_W = 5000;

int main(){
	short s,d,m;
	
	while(~scanf("%hd %hd %hd",&s,&d,&m)){		

		map<short,vector<Goods> > data;
		for(short i=0;i<s;i++){
			short k;
			scanf("%hd",&k);
			for(short j=0;j<k;j++){
				short w,p;
				scanf("%hd %hd",&w,&p);
				data[i].push_back(Goods(w,p));
			}
		}

		vector<short> days;

		for(short i=0;i<d;i++){
			short f;
			scanf("%hd",&f);
			days.push_back(f);
		}

		
		memset(dp,0x3f,sizeof(dp));
		dp[0][0] = 0;

		for(short idx=0;idx<days.size();idx++){
			vector<Goods>& it = data[days[idx]];
			
			for(short i=0;i < it.size();i++){
				short w = it[i].w;
				short p = it[i].p;
				for(short j=0;j<=MAX_W;j++){		
					if(j-w >= 0){
						dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+p);
					}
					else{
						dp[idx+1][j] = min(dp[idx+1][j],dp[idx][j]);
					}
				}
			}
		}

		short resw=0;
		short resm=0;
		for(short i=0;i<=MAX_W;i++){
			if(dp[d][i] <= m){
				resm = dp[d][i];
				resw = i;
			}
		}

		printf("%hd %hd\n",resw,resm);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:67: error: no matching function for call to 'min(const short int&, int)'
   79 |                                                 dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+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:4:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:79:67: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   79 |                                                 dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+p);
      |                                                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:79:67: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   79 |                                                 dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+p);
      |                                                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~