PriorityQueue to track the min time used till current location
Intuition\n Describe your first thoughts on how to solve this problem. \ncorrectly understand the meaning of "alternating between the two." is the core part of 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncorrectly understand the meaning of "alternating between the two." is the core part of this question.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```csharp []\npublic class Solution {\n    public int MinTimeToReach(int[][] moveTime) {\n        int[] dir = new int[]{0, 1, 0, -1, 0};\n        int row = moveTime.Length, col = moveTime[0].Length, res = int.MaxValue;\n        int[,] dp = new int[row, col];\n        for(int i = 0; i < row; i++)\n        {\n            for(int j = 0; j < col; j++)\n            {\n                dp[i, j] = -1;\n            }\n        }\n\n        PriorityQueue<(int, int, bool), int> que = new();\n        que.Enqueue((0, 0, false), 0);\n\n        while(que.Count > 0)\n        {\n            if(que.TryDequeue(out var cur, out int time))\n            {\n                (int x, int y, bool alter) = cur;\n\n                if(time >= res || dp[x, y] >= 0 && dp[x, y] <= time)\n                    continue;\n\n                dp[x, y] = time;\n                for(int p = 0; p < 4; p++)\n                {\n                    int newX = x + dir[p], newY = y + dir[p+1];\n                    if(newX < 0 || newY < 0 || newX >= row || newY >= col)\n                        continue;\n\n                    int newTime = Math.Max(moveTime[newX][newY], time) + (alter ? 2 : 1);\n                    if(newTime < res)\n                    {\n                        if(newX == row-1 && newY == col-1)\n                        {\n                            res = Math.Min(res, newTime);\n                            dp[newX, newY] = Math.Min(dp[newX, newY], newTime);\n                        }\n                        else\n                            que.Enqueue((newX, newY, !alter), newTime);\n                    }\n                }\n            } \n        }\n\n        return res;\n    }\n}\n```
['C#']