Maximum Product of Subsequences With an Alternating Sum Equal to K
Track, for each parity and alternating sum, the set of products still under the limit, and read off the largest product whose alternating sum equals k.
Track, for each parity and alternating sum, the set of products still under the limit, and read off the largest product whose alternating sum equals k.