QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22385. 股票市場

Statistics

乳牛雖天生謹慎,卻在住房抵押貸款市場遭受重創,現在轉而嘗試股票。幸運的是 Bessie 能預知未來,不僅知道今天 $S$ $(2 \le S \le 50)$ 種股票的價格,還知道總共 $D$ 天 $(2 \le D \le 10)$ 的未來價格。

給定各天目前和未來價格的矩陣 $(1 \le PR_{sd} \le 1,000)$ 及初始資金 $M$ $(1 \le M \le 200,000)$,選擇最優買賣策略,使最後一天賣出後的收益最大。只能買整數股,無須用完資金,甚至可以完全不花。保證獲利不可能超過 500,000。

考慮下例 Bessie 最愛的牛市(上漲市場):$S=2$ 種股票,$D=3$ 天,乳牛有 10 資金投資。表中各欄是今天、明天、後天的價格:

                   Today's price
                   |   Tomorrow's price
                   |   |  Two days hence
             Stock |   |  | 
              1    10 15 15
              2    13 11 20

要賺錢,第一天必須買股票 1。第二天賣出,馬上買股票 2,此時銀行有 4,持有股票 2 一股。最後一天賣出得到 20,加上銀行的 4,共 24。

輸入格式

  • 第 1 行:空格分隔的三個整數 $S$、$D$、$M$。
  • 第 $2,\ldots,S+1$ 行:第 $s+1$ 行包含股票 $s$ 在第 $1,\ldots,D$ 天的 $D$ 個價格 $PR_{sd}$。

輸出格式

  • 第 1 行:第 $D$ 天賣出後能擁有的最大資金。

範例

輸入格式 1

2 3 10
10 15 15
13 11 20

輸出格式 1

24

題目作者:Rob Kolstad(?),2008

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.