zoukankan      html  css  js  c++  java
  • Codeforces Round #707 (Div. 2, based on Moscow Open Olympiad in Informatics Editorial

    Codeforces Round #707 (Div. 2, based on Moscow Open Olympiad in Informatics)

    Problem 1501A. Alexey and Train

    按题意,比较到站的最大值.

    using ll = long long;
    int a[105], b[105], c[105];
    int main() {
        // ios_base::sync_with_stdio(false), cin.tie(0);
        int _;
        for (cin >> _; _--;) {
            int n, s = 0;
            scanf("%d", &n);
            for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
            for (int i = 1; i <= n; i++) {
                scanf("%d", &c[i]), s += a[i] - b[i - 1] + c[i];
                if (i == n) break;
                s = max(s + (b[i] - a[i] + 1) / 2, b[i]);
            }
            cout << s << "
    ";
        }
        return 0;
    }
    

    Problem 1501B. Napoleon Cake

    从后往前比较.

    int arr[200001];
    int res[200001];
    int main() {
        ios_base::sync_with_stdio(false), cin.tie(0);
        int _ = 1;
        for (cin >> _; _--;) {
            int n, i, mn = 1e9;
            cin >> n;
            for (i = 1; i <= n; i++) cin >> arr[i];
            for (i = n; i >= 1; i--) {
                mn = min(mn, i - arr[i]);
                res[i] = (mn < i);
            }
            for (i = 1; i <= n; i++) cout << res[i] << " ";
            cout << endl;
        }
        return 0;
    }
    

    Problem 1501C. Going Home

    把两数之和想象成坐标,x 和 y

    使用双指针然后存储和存储一下,如果能匹配并且 坐标不重复即可输出。

    数组开大点,这个导致WA好几次了....

    const int N = 5000003;
    int x[N], y[N], a[N];
    int main() {
        ios_base::sync_with_stdio(false), cin.tie(0);
        int n;
        cin >> n;
        for (int i = 1; i <= n; ++i) cin >> a[i];
        for (int i = 1; i <= n; ++i)
            for (int j = i + 1; j <= n; ++j) {
                int s = a[i] + a[j];
                if (x[s] && y[s] && x[s] != i && y[s] != j && x[s] != j &&
                    y[s] != i) {
                    cout << "YES
    ";
                    cout << i << " " << j << " " << x[s] << " " << y[s] << "
    ";
                    return 0;
                }
                x[s] = i;
                y[s] = j;
            }
        cout << "NO
    ";
        return 0;
    }
    

    The desire of his soul is the prophecy of his fate
    你灵魂的欲望,是你命运的先知。

  • 相关阅读:
    BZOJ 3218: a + b Problem
    P4542 [ZJOI2011]营救皮卡丘
    P4843 清理雪道
    P4553 80人环游世界
    P4126 [AHOI2009]最小割
    P2619 [国家集训队2]Tree I
    P2469 [SDOI2010]星际竞速
    P2050 [NOI2012]美食节
    易语言入门
    jdbc连接oracle语法
  • 原文地址:https://www.cnblogs.com/RioTian/p/14539864.html
Copyright © 2011-2022 走看看