zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 108 (Rated for Div. 2)

    Educational Codeforces Round 108 (Rated for Div. 2)

    A - Red and Blue Beans

    int main() {
        IOS;
        for (cin >> _; _; --_) {
            cin >> n >> m >> k;
            if (n > m) swap(n, m);
            m -= n;
            cout << (!m || (m - 1) / n + 1 <= k ? "YES
    " : "NO
    ");
        }
        return 0;
    }
    

    B - The Cake Is a Lie

    int main() {
        IOS;
        for (cin >> _; _; --_) {
            cin >> n >> m >> k;
            if (n < m) swap(n, m);
            k -= n - 1 + (m - 1ll) * n;
            cout << (!k ? "YES
    " : "NO
    ");
        }
        return 0;
    }
    

    C - Berland Regional

    排序之后对每个学校算对每种人数组队的贡献即可

    int u[N];
    ll s[N];
     
    int main() {
        IOS;
        for (cin >> _; _; --_) {
            cin >> n; map<int, vector<ll>> st;
            rep (i, 1, n) cin >> u[i], s[i] = 0;
            rep (i, 1, n) cin >> k, st[u[i]].pb(k);
            for (auto &i : st) {
                sort(all(i.se), greater<int>());
                rep (j, 1, i.se.size() - 1) i.se[j] += i.se[j - 1];
                rep (j, 1, i.se.size()) s[j] += i.se[i.se.size() / j * j - 1];
            }
            rep (i, 1, n) cout << s[i] << char(" 
    "[i == n]);
        }
        return 0;
    }
    

    D - Maximum Sum of Products

    区间dp模型

    int a[N], b[N];
    ll sum, mx, s[N][N];
     
    int main() {
        IOS; cin >> n;
        rep (i, 1, n) cin >> a[i];
        rep (i, 1, n) cin >> b[i], sum += (ll)a[i] * b[i];
        rep (i, 2, n) rep (j, 1, n + 1 - i)
            umax(mx, s[j][i + j - 1] = s[j + 1][i + j - 2] + (ll)(a[i + j - 1] - a[j]) * (b[j] - b[i + j - 1]));
        cout << (sum + mx);
        return 0;
    }
    
  • 相关阅读:
    MARKDOWN测试文章
    忘记网站登录密码实现快速查看
    IDEA debug下取消后续操作
    GitHub上传文件
    注解学习
    异常
    快捷键
    Android反编译三件套 apktool 、dex2jar、jd-gui
    ILSpy反编译工具之C#反汇编
    MAVEN配置及Spring Tool Suite的Maven配置
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/14721715.html
Copyright © 2011-2022 走看看