Submission #1103540
Source Code Expand
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)
int dp[44][444][444];
const int INF = 1e9 + 7;
int N,A,B;
int main(){
scanf("%d%d%d" , &N , &A , &B);
repp(i,0,N+1){
repp(j,0,444){
fill(dp[i][j],dp[i][j]+444,INF);
}
}
dp[0][0][0] = 0;
repp(i,1,N+1){
int x,y,z;
scanf("%d%d%d" , &x , &y , &z);
repp(j,0,401){
repp(k,0,401){
dp[i][j][k] = dp[i-1][j][k];
}
}
repm(j,400-x,-1){
repm(k,400-y,-1){
dp[i][j+x][k+y] = min(dp[i][j+x][k+y] , dp[i-1][j][k] + z);
}
}
}
int ans = INF;
for(int i = 1 ; i * A <= 400 && i * B <= 400 ; ++i){
ans = min(ans , dp[N][i*A][i*B]);
}
if(ans == INF){
printf("-1\n");
} else {
printf("%d\n" , ans);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Mixing Experiment |
User |
PIandS |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1431 Byte |
Status |
AC |
Exec Time |
29 ms |
Memory |
32896 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:29:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d" , &N , &A , &B);
^
./Main.cpp:38:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d" , &x , &y , &z);
^
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 |
4 ms |
4224 KB |
sample_02.txt |
AC |
2 ms |
1664 KB |
subtask_1_01.txt |
AC |
5 ms |
6272 KB |
subtask_1_02.txt |
AC |
3 ms |
4224 KB |
subtask_1_03.txt |
AC |
5 ms |
6272 KB |
subtask_1_04.txt |
AC |
8 ms |
10368 KB |
subtask_1_05.txt |
AC |
10 ms |
12416 KB |
subtask_1_06.txt |
AC |
14 ms |
16512 KB |
subtask_1_07.txt |
AC |
16 ms |
18560 KB |
subtask_1_08.txt |
AC |
18 ms |
20608 KB |
subtask_1_09.txt |
AC |
20 ms |
22656 KB |
subtask_1_10.txt |
AC |
24 ms |
26752 KB |
subtask_1_11.txt |
AC |
28 ms |
30848 KB |
subtask_1_12.txt |
AC |
29 ms |
32896 KB |
subtask_1_13.txt |
AC |
29 ms |
32896 KB |
subtask_1_14.txt |
AC |
29 ms |
32896 KB |
subtask_1_15.txt |
AC |
29 ms |
32896 KB |
subtask_1_16.txt |
AC |
29 ms |
32896 KB |
subtask_1_17.txt |
AC |
29 ms |
32896 KB |
subtask_1_18.txt |
AC |
29 ms |
32896 KB |