Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ratioA = sc.nextInt();
    int ratioB = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    int[] c = new int[N];
    int sumA = 0;
    int sumB = 0;
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextInt();
      sumA += a[i];
      sumB += b[i];
    }
    int[][][] dp = new int[401][401][N];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < 401; j++) {
        for(int k = 0; k < 401; k++) {
          dp[j][k][i] = -1;
        }
      }
    }
    dp[a[0]][b[0]][0] = c[0];
    for(int i = 1; i < N; i++) {
      for(int j = 0; j < 401; j++) {
        for(int k = 0; k < 401; k++) {
          if(a[i] <= j && b[i] <= k) {
            int a = Integer.MAX_VALUE;
            if(a[i] == j && b[i] == k) {
              a = c[i];
            } else {
              if(dp[j - a[i]][k - b[i]] != -1) a = c[i] + dp[j - a[i]][k - b[i]];
            }
            if(dp[j][k][i - 1] == -1) {
              if(a == Integer.MAX_VALUE) {
                dp[j][k][i] = -1;
              } else {
                dp[j][k][i] = a;
              }
            } else {
              dp[j][k][i] = Math.min(a, dp[j][k][i - 1]);
            }
          } else {
            dp[j][k][i] = dp[j][k][i - 1];
          }
        }
      }
    }
    int cost = Integer.MAX_VALUE;
    for(int i = 1; i <= Math.min(sumA / ratioA, sumB / ratioB); i++) {
      if(dp[ratioA * i][ratioB * i] != -1) {
        cost = Math.min(cost, dp[ratioA * i][ratioB * i]);
      }
    }
    int res = "";
    if(cost != Integer.MAX_VALUE) {
      res = cost;
    } else {
      res = -1;
    }
    System.out.println(res);
  }
}

Compiler output:
Main.java:34: error: variable a is already defined in method main(String[])
            int a = Integer.MAX_VALUE;
                ^
Main.java:35: error: array required, but int found
            if(a[i] == j && b[i] == k) {
                ^
Main.java:38: error: array required, but int found
              if(dp[j - a[i]][k - b[i]] != -1) a = c[i] + dp[j - a[i]][k - b[i]];
                         ^
Main.java:38: error: bad operand types for binary operator '!='
              if(dp[j - a[i]][k - b[i]] != -1) a = c[i] + dp[j - a[i]][k - b[i]];
                                        ^
  first type:  int[]
  second type: int
Main.java:38: error: array required, but int found
              if(dp[j - a[i]][k - b[i]] != -1) a = c[i] + dp[j - a[i]][k - b[i]];
                                                                  ^
Main.java:38: error: bad operand types for binary operator '+'
              if(dp[j - a[i]][k - b[i]] != -1) a = c[i] + dp[j - a[i]][k - b[i]];
                                                        ^
  first type:  int
  second type: int[]
Main.java:57: error: bad operand types for binary operator '!='
      if(dp[ratioA * i][ratioB * i] != -1) {
                                    ^
  first type:  int[]
  second type: int
Main.java:58: error: no suitable method found for min(int,int[])
        cost = Math.min(cost, dp[ratioA * i][ratioB * i]);
                   ^
    method Math.min(int,int) is not applicable
      (argument mismatch; int[] cannot be converted to int)
    method Math.min(long,long) is not applicable
      (argument mismatch; int[] cannot be converted to long)
    method Math.min(float,float) is not applicable
      (argument mismatch; int[] cannot be converted to float)
    method Math.min(double,double) is not applicable
      (argument mismatch; int[] cannot be converted to double)
Main.java:61: error: incompatible types: String cannot be converted to int
    int res = "";
              ^
9 errors