Record: 2016-08-15 22:19:04 background mm Tanabata simulation description "Find AH find ah find GF, find a good gf, have a meal Ah lala hand, you are my good gf." Goodbye. "
"Eh, don't see again ..."
Tanabata... Tanabata... Tanabata this day, for Sqybi This single rookie is how painful ... Although he listened to this song called "Find Ah find ah find GF", he is still very painful. To avoid the pain, Sqybi decided to find something to do. He went to find the person in charge of the Tanabata simulation game zmc mm, let her give herself a task of the issue. After a few days of the stalker, ZMC MM finally agreed.
However, the Sqybi found that the task was more boring than single-_-.... So, he decided to, in the meantime, to do another thing that can make oneself not bored-to find GF.
Sqybi now fancy n mm, we might as well put them number 1 to n. Please mm eat is to spend money, we assume that please I number mm eat to spend rmb[i] block of ocean. and want to cheat mm when their gf is to pay the character, we assume that the number I mm eat try to let her when their GF behavior ( It may be called bubble this mm) to consume rp[i] character. And for each mm, Sqybi has a corresponding to the time to fix her, for the first mm is called Time[i]. Sqybi to ensure that he has enough charm with time[i] time to finish the first mm ^_^.
Sqybi want to get as many as possible mm when their GF, this is no doubt. But he doesn't want to spend too much time on it (after all, the theme of the Tanabata game has not yet come out), so he would like to ensure that the maximum number of MM in the case of the total amount of time spent.
Sqybi now has m block of ocean, he also through a period of effort to save R's character (this time for the simulation game also save RP Oh ~ ~). With these oceans and personalities he can soak up some mm. He wants to know the minimum amount of time it takes to soak up the MM.
Note that Sqybi in a moment can only go to soak a mm--if you bubble two or more mm at the same time, they will fight up ... Input format the first line of input is N, which indicates the number of MM Sqybi fancy. Next there are n lines, which in turn denote a mm of information numbered 1, 2, 3, ..., N. Each line represents a mm of information, with three integers: $, RP, and time. The last line has two integers, M and R. Output format you only need to output a line with an integer that represents the minimum total time that the Sqybi spends in the case of a number of MM. Test Sample 1 input
4
1 2 5
2 1 6
2 2 2
2 2 3
5 5
Output
-
Memo Data size
For 20% data,1<=n<=10;
For 100% data,1<=rmb<=100,1<=rp<=100,1<=time<=1000;
For 100% data, 1<=m<=100,1<=r<=100,1<=n<=100. Code
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespacestd;intn,m,r,f[ the][ the],g[ the][ the],ANS,MN;//F Quantity G timestructcc{intRmb,rp,time;} a[ the];intMain () {//freopen ("01.txt", "R", stdin);Memset (G,127,sizeof(g)); scanf ("%d",&N); for(intI=1; i<=n;i++) scanf ("%d%d%d",&a[i].rmb,&a[i].rp,&a[i].time); scanf ("%d%d", &m,&r);//M--RMB R--RP intinf=g[0][0]; g[0][0]=0; for(intI=1; i<=n;i++){ for(intj=m;j>=a[i].rmb;j--){ for(intk=r;k>=a[i].rp;k--){ if(g[j-a[i].rmb][k-a[i].rp]<inf) { if(F[J][K]<F[J-A[I].RMB][K-A[I].RP] +1) {F[j][k]=f[J-A[I].RMB] [K-A[I].RP] +1; G[J][K]=g[J-A[I].RMB] [K-A[I].RP] +A[i].time; } if(F[J][K]==F[J-A[I].RMB][K-A[I].RP] +1) {G[j][k]=min (G[j][k], g[J-A[I].RMB [K-A[I].RP] +a[i].time); } if(f[j][k]>ans) {ans=F[j][k]; MN=G[j][k]; } if(f[j][k]==ans) {MN=min (mn,g[j][k]);//printf ("i=%d ans=%d mn=%d\n", i,ans,mn);}}}}} printf ("%d\n", MN); return 0;}
"tyvj1013" Look for Ah, find a GF
Use f(I,J)F (i,j) to indicate consumption I money J point Rp can bubble to the most sister
Make a 01 backpack
Use g(i,J)g (i,j) to indicate the minimum cost
Note In reverse order, 1h, one of the reasons is the sequence, causing the previous state to be destroyed
TYVJ P1013 looking for, looking for GF Label: Dynamic Planning