P1968 美元汇率 怀疑智商超过海平面

https://www.luogu.org/problemnew/show/P1968

 

也是一道贪心题,一些计算;

然而我却弄得很复杂;

既然我们要的是最后的最大值,那我们为什么要注意中间的细节呢;

记录每天我们能拿到的最大值,然后输出,完美结束;

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=200;
int n;
double to_us[maxn],to_mark[maxn],a[maxn];
int cnt,vis;
double ans=100,ans2=100;
double max_us=100,max_mark;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lf",a+i);
        to_mark[i]=a[i]/100;
        to_us[i]=100/a[i];
    }
    for(int i=1;i<=n;i++)
    {
        max_us=max(max_us,max_mark*to_us[i]);
        max_mark=max(max_mark,max_us*to_mark[i]);
    }
    printf("%.2lf",max_us);
    return 0;
}

 

posted @ 2019-07-20 19:39  AiRomance  阅读(155)  评论(0编辑  收藏  举报