Language: C++

#include<bits/stdc++.h>
typedef short ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF (30000)
ll gcd (ll a,ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b,a % b);
}

ll n,ma,mb,a[100],b[100],c[100];
ll dp[41][2500][2500];

int main(){

	cin >> n;

	cin >> ma >> mb;

	REP(i,n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	REP(k,n + 1){
		REP(i,1001) {
			REP(j,1001) {
				dp[k][i][j] = INF;
			}
		}
	}
	dp[0][0][0] = 0;

	REP(i,n) {
		REP(k,1001) {
			REP(l,1001) {
				dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]);
				dp[i + 1][k][l] = min(dp[i + 1][k][l],dp[i][k][l]);
			}
		}
	}
	
	ll ans = INF;
	FOR(i,1,1001) {
		FOR(j,1,1001) {
			ll g = gcd(i,j);

			if(i / g == ma && j / g == mb) {
				ans = min(ans,dp[n][i][j]);
			}
		}
	}
	if(ans < INF) {
		cout << ans << endl;
	}else {
		cout << -1 << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:68: error: no matching function for call to 'min(ll&, int)'
   49 |                                 dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: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:49:68: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   49 |                                 dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:49:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   49 |                                 dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~