AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 商店
  • 应用
  • 文章
    • 题解
    • 分享
    • 问答
  • 吐槽
  • 登录/注册

AcWing 1952. 金发姑娘和 N 头牛 0.07 AC币

作者: 作者的头像   4_3 ,  2022-01-13 22:46:44 ,  所有人可见 ,  阅读 20


0


#include <iostream>
#include <cstring>
#include <algorithm>
#define x first
#define y second

using namespace std;

typedef pair<int, int> PII;

const int N = 40010;

PII ps[N];
int n, X, Y, Z, ans;

int main()
{
    scanf("%d%d%d%d", &n, &X, &Y, &Z);

    for (int i = 1; i < n * 2; i += 2)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        ps[i] = {a, Y - X};
        ps[i + 1] = {b + 1, Z - Y};
    }

    sort(ps + 1, ps + n * 2 + 1);

    int res = n * X;
    for (int i = 1; i <= n * 2; i ++)
    {
        res += ps[i].y;
        ans = max(ans, res);
    }

    printf("%d", ans);

    return 0;
}

0 评论

你确定删除吗?
1024
x

© 2018-2022 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息