【HDOJ】1963 Investment

完全背包。

 #include <stdio.h>
#include <string.h> #define max(a, b) (a>b) ? a:b int val[], an[];
int dp[]; int main() {
int case_n;
int n, m, year;
int i, j, k; scanf("%d", &case_n); while (case_n--) {
scanf("%d %d", &m, &year);
scanf("%d", &n);
for (i=; i<=n; ++i) {
scanf("%d %d", &val[i], &an[i]);
val[i] /= ;
}
for (k=; k<=year; ++k) {
memset(dp, , sizeof(dp));
for (i=; i<=n; ++i) {
for (j=val[i]; j<=m/; ++j)
dp[j] = max(dp[j], dp[j-val[i]]+an[i]);
}
//printf("%dyear:%d\n", k, dp[m/1000]);
m += dp[m/];
}
printf("%d\n", m);
} return ;
}
上一篇:bzoj千题计划148:bzoj1537: [POI2005]Aut- The Bus


下一篇:jenkins服务器上安装配置Android SDK