P5785求调,全WA了
  • 板块灌水区
  • 楼主zhanglh
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/8/21 20:33
  • 上次更新2023/11/3 02:08:50
查看原帖
P5785求调,全WA了
726862
zhanglh楼主2023/8/21 20:33
#include <cstdio>

using namespace std;

typedef long long LL;

const int N = 300010;

int n, s;
LL t[N], c[N];
LL f[N];
int q[N];

int main()
{
    scanf("%d%d", &n, &s);
    for (int i = 1; i <= n; i ++ )
    {
        scanf("%lld%lld", &t[i], &c[i]);
        t[i] += t[i - 1];
        c[i] += c[i - 1];
    }
    
    int hh = 0, tt = 0;
    for (int i = 1; i <= n; i ++ )
    {
        int l = hh, r = tt;
        while (l < r)
        {
            int mid = l + r >> 1;
            if ((f[q[mid + 1]] - f[q[mid]]) > (t[i] + s) * (c[q[mid]] - c[q[mid + 1]])) r = mid;
            l = mid + 1;
        }
        int j = q[r];
        f[i] = f[j] - (t[i] * s) * c[j] + t[i] * c[i] + c[n] * s;
        while (hh < tt && (double)(f[q[tt]] - f[q[tt - 1]]) * (c[i] - c[q[tt]]) >= (double)(f[i] - f[q[tt]]) * (c[q[tt]] - c[q[tt - 1]])) tt -- ;
        q[ ++ tt] = i;
    }
    
    printf("%lld\n", f[n]);
    
    return 0;
}

现在心情真的特别特别的极端的差,极其痛苦,还很困,实在不想调了qwq,交给讨论区吧,感谢

2023/8/21 20:33
加载中...