# CSU2026 Daydreaming Stockbroker（贪心）

## Daydreaming Stockbroker

• Time Limit: 1 Sec
• Memory Limit: 512 Mb
• Submitted: 67
• Solved: 20

### Description

Gina Reed, the famous stockbroker, is having a slow day at work, and between rounds of solitaire she is daydreaming. Foretelling the future is hard, but imagine if you could just go back in time and use your knowledge of stock price history in order to maximize your profits!

### Sample Input

6
100
200
100
150
125
300

### Sample Output

650

### 链接

http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2026

### 代码

StatusAccepted
Memory2024kB
Length640
// money当前拥有总价值，curprice记录当前交易价格，number记录可购买的升值股数
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;

int main()
{
int n;
scanf("%d", &n);
ll money = 100, curprice = 100, number = 0, x = 0;
for (int i = 0; i < n; ++i)
{
scanf("%lld", &x);
if (x <= curprice) // 低价
{
number = money / x; // 可购买数量
curprice = x; // 当前价格
}
if (number > 100000) // 数量超出限制
number = 100000;
if (x > curprice) // 高价
{
money += number * (x - curprice); // 利润
curprice = x;
}
}
printf("%lld\n", money);
return 0;
}

The end.
2018-08-27 星期一