dp
rust []\nimpl Solution {\n    pub fn max_score(n: i32, k: i32, stay_score: Vec<Vec<i32>>, travel_score: Vec<Vec<i32>>) -> i32 {\n        let n = n as usize;\n  
```rust []\nimpl Solution {\n    pub fn max_score(n: i32, k: i32, stay_score: Vec<Vec<i32>>, travel_score: Vec<Vec<i32>>) -> i32 {\n        let n = n as usize;\n        let k = k as usize;\n        let mut dp = vec![vec![0; n]; 2];\n        let mut r = 0;\n        let (mut b, mut a) = (1,0); // old and new value\n        for d in 0..k {\n            (a,b) = (b,a);\n            for i in 0..n {\n                dp[a][i] = dp[b][i] + stay_score[d][i];\n                for j in 0..n {\n                    dp[a][i] = dp[a][i].max(dp[b][j] + travel_score[j][i]);\n                }\n                r = r.max(dp[a][i])\n            }\n        }        \n        r\n    }\n}\n\n```
[]