Tap here to switch tabs
Problem
Submissions

Problem: Maximum Points Tourist Can Earn

med
30 min
Try to solve the Maximum Points Tourist Can Earn problem.

Statement

You are given two integers, n and k, representing the total number of cities numbered from 00 to n −1- 1, and the total number of days of a journey, respectively.

You are also given two 2extD2 ext{D} integer arrays:

  • stayScore of size k $ imes$ n, where stayScore[i][j] represents the points earned if you remain in city j on day i.

  • travelScore of size n $ imes$ n, where travelScore[i][j] represents the points earned if you travel from city i to city j.

You may choose to start your journey in any city on day 00.

On each day i from day 00 to day k −1- 1, assuming your current location is city curr, you can perform exactly one of the following actions:

  • Stay in city curr and earn stayScore[i][curr] points.

  • Travel to any other city dest and earn travelScore[curr][dest] points, which updates your current location to city dest for the next day.

Return the maximum total points you can accumulate over the k days.

Constraints:

  • 1≤1 \leq n ≤200\leq 200

  • 1≤1 \leq k ≤200\leq 200

  • n ==== travelScore.length ==== travelScore[i].length ==== stayScore[i].length

  • k ==== stayScore.length

  • 1≤1 \leq stayScore[i][j] ≤100\leq 100

  • 0≤0 \leq travelScore[i][j] ≤100\leq 100

  • travelScore[i][i] ==0== 0

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Points Tourist Can Earn

med
30 min
Try to solve the Maximum Points Tourist Can Earn problem.

Statement

You are given two integers, n and k, representing the total number of cities numbered from 00 to n −1- 1, and the total number of days of a journey, respectively.

You are also given two 2extD2 ext{D} integer arrays:

  • stayScore of size k $ imes$ n, where stayScore[i][j] represents the points earned if you remain in city j on day i.

  • travelScore of size n $ imes$ n, where travelScore[i][j] represents the points earned if you travel from city i to city j.

You may choose to start your journey in any city on day 00.

On each day i from day 00 to day k −1- 1, assuming your current location is city curr, you can perform exactly one of the following actions:

  • Stay in city curr and earn stayScore[i][curr] points.

  • Travel to any other city dest and earn travelScore[curr][dest] points, which updates your current location to city dest for the next day.

Return the maximum total points you can accumulate over the k days.

Constraints:

  • 1≤1 \leq n ≤200\leq 200

  • 1≤1 \leq k ≤200\leq 200

  • n ==== travelScore.length ==== travelScore[i].length ==== stayScore[i].length

  • k ==== stayScore.length

  • 1≤1 \leq stayScore[i][j] ≤100\leq 100

  • 0≤0 \leq travelScore[i][j] ≤100\leq 100

  • travelScore[i][i] ==0== 0