Annotated C++ Solution
Bog standard c++ implementation based on the question hint.\n\n# Code\ncpp\nclass Solution {\npublic:\n    int minimumTime(vector<int>& nums1, vector<int>& nums
Bog standard c++ implementation based on the question hint.\n\n# Code\n```cpp\nclass Solution {\npublic:\n    int minimumTime(vector<int>& nums1, vector<int>& nums2, int x) {\n        \n        // 1.0 Define number of nodes to be used throughout this function.\n        int n = nums1.size();\n\n        // 1.1 Create a map of each element in nums2 and nums1,\n        //     allowing for sorting based on the values in nums2.\n        vector<pair<int, int>> num2num1;\n        for (int i = 0; i < n; i++) {\n            num2num1.push_back({nums2[i], nums1[i]});\n        }\n        sort(num2num1.begin(), num2num1.end());\n\n        // 1.2 Create a 2D DP vector.\n        vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));\n\n        // 2.0 Populate the DP vector from smallest to largest element\n        //     in num2, over the number of ops up to n.\n        int ops = 1;\n        for (auto it = num2num1.begin(); it != num2num1.end(); it++) {\n            for (int sec = 1; sec <= ops; sec++) {\n                \n                int num2 = (*it).first;\n                int num1 = (*it).second;\n\n                // These two lines are the key to this problem.\n                int skipNum2 = dp[ops - 1][sec];\n                int useNum2 = dp[ops - 1][sec - 1] + num2 * sec + num1;\n\n                dp[ops][sec] = max(skipNum2, useNum2);\n            }\n            ops++;\n        }\n\n        // 3.0 Find the smallest time `t` using the dp matrix that\n        //     satisfies the sum threshold.\n        int sum1 = reduce(nums1.begin(), nums1.end());\n        int sum2 = reduce(nums2.begin(), nums2.end());\n        for (int t = 0; t <= n; t++) {\n            if (sum1 + sum2 * t - dp[n][t] <= x) {\n                return t;\n            }\n        }\n\n        return -1;\n    }\n};\n```
['C++']