萌新刚学OI,75ptsWA求助
查看原帖
萌新刚学OI,75ptsWA求助
590386
_LX_楼主2022/10/26 13:47
#include <bits/stdc++.h>
using namespace std;
double l, c, d, p, ans;
int n;
struct Node
{
    double d, p;
} node[10086];
int main()
{
    scanf("%lf%lf%lf%lf%d", &l, &c, &d, &p, &n);
    l /= d;
    node[0].d = 0;
    node[0].p = p;
    for (int i = 1; i <= n; i++)
    {
        scanf("%lf%lf", &node[i].d, &node[i].p);
        node[i].d /= d;
    }
    node[n+1].d = l;
    node[n+1].p = -1;
    ans+=node[0].p*c;
    for (int i = 0; i <= n;)
    {
        // // cout<<i;
        int j = i + 1, minl = i, minn = 1e9;
        while (node[j].d - node[i].d <= c && node[j].p > node[i].p && j <= n)
        {
            if (node[j].p <= minn)
            {
                minn = node[i].p;
                minl = j;
            }
            j++;
        }
        // // cout<<j;
        if (node[j].d-node[i].d>c&&minl==i)
        {
            printf("No Solution");
            return 0;
        }
        else if(j>=n+1){
            ans-=(c-(l-node[i].d))*node[i].p;
            break;
        }
        else if (node[j].d - node[i].d <= c)
        {
            ans -= (c-(node[j].d - node[i].d)) * node[i].p;
            ans+=c*node[j].p;
            // printf("%lf\n",node[j].p*c);
            i = j;
        }
        else
        {
            ans += (node[minl].d - node[i].d) * node[i].p;
            i = minl;
        }
    }
    // cout<<ans;
    printf("%.2lf", ans);
    return 0;
}

#4WA
#4输入

475.6 11.9 27.4 14.98 6
102.0 9.99
220.0 13.29
256.3 14.79
275.0 10.29
277.6 11.29
381.8 10.09

#4答案

192.15

#4输出

191.98
2022/10/26 13:47
加载中...