Daydreaming Stockbroker Gym-101550D
// 低买高卖
// 贪心,把序列分成若干连续的不减段,对每一段,在最小值处买,在最大值处卖
#include <stdio.h>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
int
main() {
int d, prev, cur, i;
long long money, ceil; //
scanf("%d", &d);
prev = INF;
money = 100;
ceil = 100000;
for( i = 0; i < d; i++ ) {
scanf("%d", &cur);
if( cur > prev ) {
money += min(money / prev, ceil) * (cur - prev);
}
prev = cur;
}
printf("%lld", money);
return 0;
}