Simple Solution beats 100% using priority queue
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\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```cpp []\nclass Solution {\npublic:\n    int minTimeToReach(vector<vector<int>>& moveTime) {\n        priority_queue<pair<pair<int, int>, pair<int, int>>, vector<pair<pair<int, int>, pair<int, int>>>, greater<pair<pair<int, int>, pair<int, int>>>> pq;\n        pq.push({{0,1},{0,0}});\n        int m = moveTime.size();\n        int n = moveTime[0].size();\n        vector<vector<int>> vis(m,vector<int>(n,INT_MAX));\n        int dx[4] = {-1,0,1,0};\n        int dy[4] = {0,1,0,-1};\n        vis[0][0] = 0;\n        while(!pq.empty()){\n            auto tp = pq.top();\n            int time = tp.first.first;\n            int alt = tp.first.second;\n            int x = tp.second.first;\n            int y = tp.second.second;\n            if(x == m-1 && y == n-1){\n                return time;\n            }\n            pq.pop();\n            for(int i = 0;i<4;i++){\n                int nx = x + dx[i];\n                int ny = y + dy[i];\n                if(nx >= 0 && nx < m && ny >= 0 && ny < n){\n                    int nextTime;\n                    if(alt){\n                        nextTime = max(time,moveTime[nx][ny])+1;\n                        if(nextTime < vis[nx][ny]){\n                            vis[nx][ny] = nextTime;\n                            pq.push({{nextTime,0},{nx,ny}});\n                        }\n                    }else{\n                        nextTime = max(time,moveTime[nx][ny])+2;\n                        if(nextTime < vis[nx][ny]){\n                            vis[nx][ny] = nextTime;\n                            pq.push({{nextTime,1},{nx,ny}});\n                        }\n                    }\n                                       \n                }\n            }\n        }\n        return -1;\n    }\n};\n```
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']