Submission #1103779
Source Code Expand
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define zhfs main
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 1; i <= n; i++)
const int INF = 1000 * 1000 * 1000 + 7;
int dp[47][107][107];
int a[47], b[47], c[47];
int zhfs()
{
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
for (int i = 0; i < 47; i++)
{
for (int j = 0; j < 107; j++)
{
for (int k = 0; k < 107; k++)
{
dp[i][j][k] = INF;
}
}
}
dp[0][0][0] = 0;
int n, ma, mb;
scanf("%d %d %d", &n, &ma, &mb);
for (int i = 1; i <= n; i++)
{
scanf("%d %d %d", &a[i], &b[i], &c[i]);
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 107; j++)
{
for (int k = 0; k < 107; k++)
{
if (dp[i][j][k] == INF) continue;
dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
dp[i + 1][j + a[i + 1]][k + b[i + 1]] = min(dp[i + 1][j + a[i + 1]][k + b[i + 1]], dp[i][j][k] + c[i + 1]);
}
}
}
int res = INF;
for (int x = 0; x < 107; x++)
{
for (int y = 0; y < 107; y++)
{
if (x != 0 && y != 0 && ma * y == mb * x)
{
res = min(res, dp[n][x][y]);
}
}
}
if (res == INF) res = -1;
printf("%d\n", res);
}
Submission Info
Submission Time |
|
Task |
D - Mixing Experiment |
User |
gritukan |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
2345 Byte |
Status |
AC |
Exec Time |
3 ms |
Memory |
2304 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:48:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &n, &ma, &mb);
^
./Main.cpp:51:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &a[i], &b[i], &c[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
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 |
2 ms |
2304 KB |
sample_02.txt |
AC |
2 ms |
2304 KB |
subtask_1_01.txt |
AC |
2 ms |
2304 KB |
subtask_1_02.txt |
AC |
2 ms |
2304 KB |
subtask_1_03.txt |
AC |
2 ms |
2304 KB |
subtask_1_04.txt |
AC |
2 ms |
2304 KB |
subtask_1_05.txt |
AC |
2 ms |
2304 KB |
subtask_1_06.txt |
AC |
3 ms |
2304 KB |
subtask_1_07.txt |
AC |
3 ms |
2304 KB |
subtask_1_08.txt |
AC |
3 ms |
2304 KB |
subtask_1_09.txt |
AC |
3 ms |
2304 KB |
subtask_1_10.txt |
AC |
3 ms |
2304 KB |
subtask_1_11.txt |
AC |
3 ms |
2304 KB |
subtask_1_12.txt |
AC |
3 ms |
2304 KB |
subtask_1_13.txt |
AC |
3 ms |
2304 KB |
subtask_1_14.txt |
AC |
3 ms |
2304 KB |
subtask_1_15.txt |
AC |
3 ms |
2304 KB |
subtask_1_16.txt |
AC |
3 ms |
2304 KB |
subtask_1_17.txt |
AC |
3 ms |
2304 KB |
subtask_1_18.txt |
AC |
3 ms |
2304 KB |