Language: C++


int main(){

    int N , Ma , Mb;
    cin >> N >> Ma >> Mb;

    int a[50] , b[50] , c[50];
    for(int i = 0 ; i < N ; i++){
        cin >> a[i] >> b[i] >> c[i];
    }



    for(int ii = 0 ; ii < 50 ; ii ++){
        for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
            for (int bi = 0; bi < nmax*abmax ; bi++) {

                dp[ii][ai][bi] = INF;
            }
        }
    }

    dp[0][0][0] = 0;


    for(int ii = 0 ; ii < N ; ii ++){
        for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
            for (int bi = 0; bi < nmax*abmax ; bi++) {
                if(dp[ii][ai][bi] == INF) continue;
                dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]);
                dp[ii+1][ai+a[ii]][bi+b[ii]] = min(dp[ii+1][ai+a[ii]][bi+b[ii]] , dp[ii][ai][bi]+c[ii]);
            }
        }
    }


    int res = INF;
    for(int ma = 1 ; ma <= nmax*abmax ; ma ++) {
        for (int mb = 1; mb <= nmax*abmax; mb++) {
            if(ma*Mb == Ma*mb){
                res = min(res , dp[N-1][ma][mb]);
            }
        }
    }

    if(res == INF) cout << -1 << endl;
    else cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> N >> Ma >> Mb;
      |     ^~~
a.cc:15:31: error: 'nmax' was not declared in this scope
   15 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                               ^~~~
a.cc:15:36: error: 'abmax' was not declared in this scope
   15 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                                    ^~~~~
a.cc:18:17: error: 'dp' was not declared in this scope
   18 |                 dp[ii][ai][bi] = INF;
      |                 ^~
a.cc:18:34: error: 'INF' was not declared in this scope
   18 |                 dp[ii][ai][bi] = INF;
      |                                  ^~~
a.cc:23:5: error: 'dp' was not declared in this scope
   23 |     dp[0][0][0] = 0;
      |     ^~
a.cc:27:31: error: 'nmax' was not declared in this scope
   27 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                               ^~~~
a.cc:27:36: error: 'abmax' was not declared in this scope
   27 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                                    ^~~~~
a.cc:29:38: error: 'INF' was not declared in this scope
   29 |                 if(dp[ii][ai][bi] == INF) continue;
      |                                      ^~~
a.cc:30:36: error: 'min' was not declared in this scope; did you mean 'main'?
   30 |                 dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]);
      |                                    ^~~
      |                                    main
a.cc:37:15: error: 'INF' was not declared in this scope
   37 |     int res = INF;
      |               ^~~
a.cc:38:28: error: 'nmax' was not declared in this scope; did you mean 'ma'?
   38 |     for(int ma = 1 ; ma <= nmax*abmax ; ma ++) {
      |                            ^~~~
      |                            ma
a.cc:38:33: error: 'abmax' was not declared in this scope
   38 |     for(int ma = 1 ; ma <= nmax*abmax ; ma ++) {
      |                                 ^~~~~
a.cc:41:23: error: 'min' was not declared in this scope; did you mean 'main'?
   41 |                 res = min(res , dp[N-1][ma][mb]);
      |                       ^~~
      |                       main
a.cc:46:20: error: 'cout' was not declared in this scope
   46 |     if(res == INF) cout << -1 << endl;
      |                    ^~~~
a.cc:46:34: error: 'endl' was not declared in this scope
   46 |     if(res == INF) cout << -1 << endl;
      |                                  ^~~~
a.cc:47:10: error: 'cout' was not declared in this scope
   47 |     else cout << res << endl;
      |          ^~~~
a.cc:47:25: error: 'endl' was not declared in this scope
   47 |     else cout << res << endl;
      |                         ^~~~