Submission #1103816


Source Code Expand

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_set>
#include <complex>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
// typedef complex<double> C;
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<vector<int> > dp(401, vector<int>(401, INF));
	dp[0][0] = 0;
	while (N--) {
		int a, b, c;
		cin >> a >> b >> c;
		for (int x = 400; x >= a; x--)
			for (int y = 400; y >= b; y--)
				dp[x][y] = min(dp[x][y], dp[x - a][y - b] + c);
	}
	int ans = INF;
	for (int x = 1; x <= 400; x++)
		for (int y = 1; y <= 400; y++)
			if (x * B == y * A)
				ans = min(ans, dp[x][y]);
	if (ans == INF) ans = -1;
	cout << ans << endl;
}

Submission Info

Submission Time
Task D - Mixing Experiment
User sugim48
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1382 Byte
Status AC
Exec Time 14 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt
Case Name Status Exec Time Memory
sample_01.txt AC 3 ms 896 KB
sample_02.txt AC 2 ms 896 KB
subtask_1_01.txt AC 3 ms 896 KB
subtask_1_02.txt AC 2 ms 896 KB
subtask_1_03.txt AC 3 ms 896 KB
subtask_1_04.txt AC 5 ms 896 KB
subtask_1_05.txt AC 6 ms 896 KB
subtask_1_06.txt AC 7 ms 896 KB
subtask_1_07.txt AC 8 ms 896 KB
subtask_1_08.txt AC 9 ms 896 KB
subtask_1_09.txt AC 10 ms 896 KB
subtask_1_10.txt AC 12 ms 896 KB
subtask_1_11.txt AC 14 ms 896 KB
subtask_1_12.txt AC 14 ms 896 KB
subtask_1_13.txt AC 14 ms 896 KB
subtask_1_14.txt AC 14 ms 896 KB
subtask_1_15.txt AC 14 ms 1024 KB
subtask_1_16.txt AC 14 ms 896 KB
subtask_1_17.txt AC 14 ms 896 KB
subtask_1_18.txt AC 14 ms 896 KB