#include <stdio.h>
#define n 6
int a[n] = {2, 5, 7, 10, 5, 2};
int b[n] = {3, 8, 4, 11, 3, 4};
int main()
{
int sumA=0;
int result=1000000;
for(int i = 0; i < n; i++){
sumA += a[i];
}
int t[sumA+1];
for(int i = 0; i <= sumA; i++)
t[i]=0;
for (int k = 0; k < n; k++) {
for (int i = sumA; i >= 0; i--) {
if ( i >= a[k])
t[i] = t[i] + b[k] < t[i-a[k]] ? t[i]+b[k] : t[i-a[k]];
else
t[i] = t[i] + b[k];
}
}
for(int i = 0; i <= sumA; i++)
{
int k = i > t[i] ? i : t[i];
if(result > k)
result = k;
}
printf(" %d", result);
return 0;
}
独立任务调度问题
最新推荐文章于 2017-10-20 20:07:06 发布