#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100
#define MAX_T 100
typedef struct Place {
char name[20];
int time;
int score;
} Place;
int max(int a, int b) {
return a > b ? a : b;
}
int main() {
Place places[] = {{"故宫", 1, 7}, {"颐和园", 2, 8}, {"长城", 3, 9}, {"天坛", 1, 6}};
int n = sizeof(places) / sizeof(places[0]);
int days = 4;
int dp[MAX_N + 1][MAX_T + 1] = {{0}};
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= days; j++) {
if (places[i-1].time > j) {
dp[i][j] = dp[i-1][j];
} else {
dp[i][j] = max(dp[i-1][j], dp[i-1][j-places[i-1].time] + places[i-1].score);
}
}
}
printf("最大价值为:%d\n", dp[n][days]);
int i = n, j = days;
while (i > 0 && j > 0) {
if (dp[i][j] != dp[i-1][j]) {
printf("%s ", places[i-1].name);
j -= places[i-1].time;
}
i--;
}
printf("\n");
return 0;
}