#include <stdio.h>
#define MAX_DAYS 4
#define MAX_SPOTS 4
typedef struct {
int time;
int score;
} Spot;
void travelPlan(Spot spots[], int n, int maxTime) {
int dp[MAX_SPOTS + 1][MAX_DAYS + 1] = {0};
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= maxTime; j++) {
if (j >= spots[i - 1].time) {
dp[i][j] = (dp[i - 1][j] > (dp[i - 1][j - spots[i - 1].time] + spots[i - 1].score)) ? dp[i - 1][j] : (dp[i - 1][j - spots[i - 1].time] + spots[i - 1].score);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
int j = maxTime;
for (int i = n; i > 0; i--) {
if (dp[i][j] != dp[i - 1][j]) {
printf("访问景点编号:%d (评分:%d, 时间:%d天)\n", i, spots[i - 1].score, spots[i - 1].time);
j -= spots[i - 1].time;
}
}
printf("最大总评分:%d\n", dp[n][maxTime]);
}
int main() {
Spot spots[MAX_SPOTS] = {
{1, 7},
{2, 8},
{3, 9},
{1, 6}
};
travelPlan(spots, MAX_SPOTS, MAX_DAYS);
return 0;
}