讨论 / c语言AC
r1529087768 2018-03-01 14:46:15
点我顶贴 收藏 删除
#include<stdio.h>

int main()

{

int i, j, k, n, m, r;

int rmb[101], rp[101], time[101];

int a[101][101][2] = {0};

scanf("%d", &n);

for(i = 0; i < n; i++)scanf("%d%d%d", &rmb[i], &rp[i], &time[i]);

scanf("%d%d", &m, &r);

for(i = 0; i < n; i++)

for(j = m; j >= rmb[i]; j--)

for(k = r; k >= rp[i]; k--)

if(a[j][k][0]==a[j-rmb[i]][k-rp[i]][0]+1 && a[j][k][1]>a[j-rmb[i]][k-rp[i]][1]+time[i] || a[j][k][0]<a[j-rmb[i]][k-rp[i]][0]+1)

{

a[j][k][1] = a[j - rmb[i]][k - rp[i]][1] + time[i];

a[j][k][0] = a[j - rmb[i]][k - rp[i]][0] + 1;

}

printf("%d", a[m][r][1]);

return 0;

}

查看更多回复
提交回复