Problem 2262. GJam 2011 Africa Qualifier B: Optimum Profit

This Challenge is derived from GJam 2011 Africa: Investing at the Market. Google Code Jam 2014 Kicks Off its Qualifier round April 11. GJam Registration. The Test Suite, at the bottom, contains a full GJam file input read (fgetl and dlmread), process, and Output example.
Determine the single optimal Buy and Sell time to optimize Profit.
If multiple cases exist then provide set with minimum Buy cost.
Investment buys are made in whole units. If no profit is possible return [0 0 0].
Input: M,x Where M is Investment and x,size(1,12), is Commodity Buy/Sell Price
Output: BSP, [BuyPt SellPt Profit]
Example: M=100; x=[52 50 25 100 61 63 70 51 71 55 10 5];
Output: 3 4 300
Additional GJam solutions can be found at Example GJam Matlab solutions. Select Find Solutions, change Language to Matlab. There were only 50 Qualifier Matlab entrants in 2013 and a mere 2 Matlab users achieved round 2.

Solution Stats

29.31% Correct | 70.69% Incorrect
Last Solution submitted on Oct 16, 2022

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers14

Suggested Problems

More from this Author294

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!