当前位置: 代码迷 >> 综合 >> Gym 101550D Daydreaming Stockbroker (贪心)
  详细解决方案

Gym 101550D Daydreaming Stockbroker (贪心)

热度:19   发布时间:2023-11-15 13:35:53.0

题目链接:http://codeforces.com/gym/101550/attachments

#include<bits/stdc++.h>
using namespace std;#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)const int  maxn =4e2+5;
const int mod=1e9+7;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}/*
买股票问题,找降序位置即可。
*/int n,a[maxn];
ll tot=100,tmp;int main()
{scanf("%d",&n);rep(i,1,n+1) scanf("%d",&a[i]);tmp=a[1];rep(i,2,n+1){if(a[i]<a[i-1]){tot+=1LL*(a[i-1]-tmp)*min(tot/tmp,100000LL);tmp=a[i];}}if(a[n]-tmp>0) tot+=1LL*(a[n]-tmp)*min(tot/tmp,100000LL);printf("%lld\n",tot);return 0;
}