Submission #34223814


Source Code Expand

#include"bits/stdc++.h"

using namespace std;


int main() {
    // freopen("B.in" , "r" , stdin);
    // freopen("B.out" , "w" , stdout);
    int n;
    long long p, q, r;
    cin >> n >> p >> q >> r;
    vector<long long> a(n+1, 0);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) a[i] += a[i-1];
    // for (int i = 1; i <= n; ++i) cout << a[i] << " ";
    // cout << endl;
    int x = 1, y = 2, z = 3, w = 4;
    int flag = 0;
    while (w <= n+1) {
        // cout << x << " " << y << " " << z << " " << w << endl;
        while (y <= n-1 && a[y-1]-a[x-1] < p) {
            y++;
        }
        while (y <= n-1 && a[y-1]-a[x-1] > p) {
            x++;
        }
        z = max(z, y+1);
        w = max(w, z+1);

        // cout << "!" << x << " " << y << " " << z << " " << w << endl;
        if (a[y-1]-a[x-1] != p) {
            continue;
        }
        while (z <= n && a[z-1]-a[y-1] < q) {
            z++;
        }
        w = max(w, z+1);

        // cout << "!" << x << " " << y << " " << z << " " << w << endl;
        if (a[z-1]-a[y-1] != q) {
            y++;
            continue;
        }
        while (w <= n && a[w-1]-a[z-1] < r) {
            w++;
        }

        // cout << "!" << x << " " << y << " " << z << " " << w << endl;
        if (a[w-1]-a[z-1] != r) {
            z++;
            continue;
        }
        flag = 1;
        break;
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task D - Iroha and Haiku (New ABC Edition)
User ZzZZCHS
Language C++ (GCC 9.2.1)
Score 400
Code Size 1591 Byte
Status AC
Exec Time 71 ms
Memory 4712 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 25
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 71 ms 4712 KiB
random_02.txt AC 41 ms 3816 KiB
random_03.txt AC 67 ms 4712 KiB
random_04.txt AC 57 ms 4388 KiB
random_05.txt AC 69 ms 4560 KiB
random_06.txt AC 54 ms 4120 KiB
random_07.txt AC 69 ms 4672 KiB
random_08.txt AC 46 ms 4128 KiB
random_09.txt AC 67 ms 4672 KiB
random_10.txt AC 45 ms 4084 KiB
random_11.txt AC 68 ms 4676 KiB
random_12.txt AC 64 ms 4552 KiB
random_13.txt AC 68 ms 4708 KiB
random_14.txt AC 53 ms 4100 KiB
random_15.txt AC 66 ms 4640 KiB
random_16.txt AC 33 ms 3568 KiB
random_17.txt AC 71 ms 4652 KiB
random_18.txt AC 2 ms 3540 KiB
random_19.txt AC 33 ms 4664 KiB
random_20.txt AC 31 ms 4644 KiB
random_21.txt AC 34 ms 4608 KiB
random_22.txt AC 2 ms 3356 KiB
sample_01.txt AC 2 ms 3476 KiB
sample_02.txt AC 2 ms 3456 KiB
sample_03.txt AC 2 ms 3468 KiB