给定一个V维度矩阵m \xc3\x97 n,其中每个元素代表农产品市场连续 n 天 m 种不同蔬菜种子的价格。此外,您还会得到一个整数t (1 \xe2\x89\xa4 n),它是您可以在矩阵中执行的最大交易数V。现在打印一个最多 t 笔交易的序列,每笔交易都涉及蔬菜种子的购买和销售,在交易种子后产生最大的利润。请注意,您必须在出售前购买种子,但您只能在出售日或之后购买另一颗(或相同的)种子。如果您无法通过出售种子获得任何利润,请在返回总利润值之前打印(0,0,0,0)或打印这样的元组列表。[(seed type index, buy day index, sell day index, profit yield)...]
Example:\nt = 3 (at most 3 transactions are allowed)\nV = [[2, 6, 3],\n [4, 2, 8]]\n\nResult:\nTotal profit yield returned is 10. Tuples: Buy seed type 0 on day 0 then sell \nit on day 1 which gives value of 4 (6-4). Then, buy seed type 1 …Run Code Online (Sandbox Code Playgroud)