Codeforces Round 901 (Div. 2) | JorbanS

A - Jellyfish and Undertale

ll solve() {
    int a, b, n; cin >> a >> b >> n;
    ll res = b;
    for (int i = 1; i <= n; i ++) {
        int x; cin >> x;
        res += min(a - 1, x);
    }
    return res;
}

B - Jellyfish and Game

ll solve() {
    int n, m, k; cin >> n >> m >> k;
    ll res = 0;
    for (int i = 1; i <= n; i ++) cin >> a[i], res += a[i];
    for (int i = 1; i <= m; i ++) cin >> b[i];
    sort(a + 1, a + n + 1), sort(b + 1, b + m + 1);
    if (k & 1) res = max(res, res + b[m] - a[1]);
    else {
        if (a[1] < b[m]) res += b[m] - a[1], swap(a[1], b[m]);
        res = min(res, res + min(b[1], b[m]) - max(a[1], a[n]));
    }
    return res;
}

C - Jellyfish and Green Apple

ll solve() {
    ll n, m; cin >> n >> m;
    n %= m;
    ll res = 0;
    int idx = 0;
    while (n) {
        res += n;
        n <<= 1;
        n %= m;
        if (++ idx == 30) return -1;
    }
    return res;
}

D - Jellyfish and Mex

int solve() {
    int n; cin >> n;
    map<int, int> mp;
    for (int i = 1; i <= n; i ++) {
        int x; cin >> x;
        mp[x] ++;
    }
    int mex = 0;
    while (mp[mex]) mex ++;
    vector<int> f(mex + 1, 1e9);
    f[mex] = 0;
    for (int i = mex; i; i --)
        for (int j = 0; j < i; j ++)
            f[j] = min(f[j], f[i] + i * (mp[j] - 1) + j);
    return f[0];
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JorbanS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值