3332. Maximum Points Tourist Can Earn Medium

@problem@discussion
#Array#Dynamic Programming#Matrix



1/**
2 * [3332] Maximum Points Tourist Can Earn
3 *
4 * You are given two integers, n and k, along with two 2D integer arrays, stayScore and travelScore.
5 * A tourist is visiting a country with n cities, where each city is directly connected to every other city. The tourist's journey consists of exactly k 0-indexed days, and they can choose any city as their starting point.
6 * Each day, the tourist has two choices:
7 * 
8 * 	Stay in the current city: If the tourist stays in their current city curr during day i, they will earn stayScore[i][curr] points.
9 * 	Move to another city: If the tourist moves from their current city curr to city dest, they will earn travelScore[curr][dest] points.
10 * 
11 * Return the maximum possible points the tourist can earn.
12 *  
13 * <strong class="example">Example 1:
14 * <div class="example-block">
15 * Input: <span class="example-io">n = 2, k = 1, stayScore = [[2,3]], travelScore = [[0,2],[1,0]]</span>
16 * Output: 3
17 * Explanation:
18 * The tourist earns the maximum number of points by starting in city 1 and staying in that city.
19 * </div>
20 * <strong class="example">Example 2:
21 * <div class="example-block">
22 * Input: <span class="example-io">n = 3, k = 2, stayScore = [[3,4,2],[2,1,2]], travelScore = [[0,2,1],[2,0,4],[3,2,0]]</span>
23 * Output: <span class="example-io">8</span>
24 * Explanation:
25 * The tourist earns the maximum number of points by starting in city 1, staying in that city on day 0, and traveling to city 2 on day 1.
26 * </div>
27 *  
28 * Constraints:
29 * 
30 * 	1 <= n <= 200
31 * 	1 <= k <= 200
32 * 	n == travelScore.length == travelScore[i].length == stayScore[i].length
33 * 	k == stayScore.length
34 * 	1 <= stayScore[i][j] <= 100
35 * 	0 <= travelScore[i][j] <= 100
36 * 	travelScore[i][i] == 0
37 * 
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/maximum-points-tourist-can-earn/
42// discuss: https://leetcode.com/problems/maximum-points-tourist-can-earn/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47    pub fn max_score(n: i32, k: i32, stay_score: Vec<Vec<i32>>, travel_score: Vec<Vec<i32>>) -> i32 {
48        0
49    }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn test_3332() {
60    }
61}
62


Back
© 2025 bowen.ge All Rights Reserved.